1 /* Convert a program in SSA form into Normal form.
2 Copyright (C) 2004, 2005 Free Software Foundation, Inc.
3 Contributed by Andrew Macleod <amacleod@redhat.com>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to
19 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
24 #include "coretypes.h"
31 #include "langhooks.h"
32 #include "hard-reg-set.h"
33 #include "basic-block.h"
37 #include "diagnostic.h"
39 #include "tree-flow.h"
40 #include "tree-gimple.h"
41 #include "tree-inline.h"
45 #include "tree-dump.h"
46 #include "tree-ssa-live.h"
47 #include "tree-pass.h"
51 /* Flags to pass to remove_ssa_form. */
53 #define SSANORM_PERFORM_TER 0x1
54 #define SSANORM_COALESCE_PARTITIONS 0x4
56 /* Used to hold all the components required to do SSA PHI elimination.
57 The node and pred/succ list is a simple linear list of nodes and
58 edges represented as pairs of nodes.
60 The predecessor and successor list: Nodes are entered in pairs, where
61 [0] ->PRED, [1]->SUCC. All the even indexes in the array represent
62 predecessors, all the odd elements are successors.
65 When implemented as bitmaps, very large programs SSA->Normal times were
66 being dominated by clearing the interference graph.
68 Typically this list of edges is extremely small since it only includes
69 PHI results and uses from a single edge which have not coalesced with
70 each other. This means that no virtual PHI nodes are included, and
71 empirical evidence suggests that the number of edges rarely exceed
72 3, and in a bootstrap of GCC, the maximum size encountered was 7.
73 This also limits the number of possible nodes that are involved to
74 rarely more than 6, and in the bootstrap of gcc, the maximum number
75 of nodes encountered was 12. */
77 typedef struct _elim_graph {
78 /* Size of the elimination vectors. */
81 /* List of nodes in the elimination graph. */
82 VEC(tree,heap) *nodes;
84 /* The predecessor and successor edge list. */
85 VEC(int,heap) *edge_list;
90 /* Stack for visited nodes. */
93 /* The variable partition map. */
96 /* Edge being eliminated by this graph. */
99 /* List of constant copies to emit. These are pushed on in pairs. */
100 VEC(tree,heap) *const_copies;
104 /* Local functions. */
105 static tree create_temp (tree);
106 static void insert_copy_on_edge (edge, tree, tree);
107 static elim_graph new_elim_graph (int);
108 static inline void delete_elim_graph (elim_graph);
109 static inline void clear_elim_graph (elim_graph);
110 static inline int elim_graph_size (elim_graph);
111 static inline void elim_graph_add_node (elim_graph, tree);
112 static inline void elim_graph_add_edge (elim_graph, int, int);
113 static inline int elim_graph_remove_succ_edge (elim_graph, int);
115 static inline void eliminate_name (elim_graph, tree);
116 static void eliminate_build (elim_graph, basic_block);
117 static void elim_forward (elim_graph, int);
118 static int elim_unvisited_predecessor (elim_graph, int);
119 static void elim_backward (elim_graph, int);
120 static void elim_create (elim_graph, int);
121 static void eliminate_phi (edge, elim_graph);
122 static tree_live_info_p coalesce_ssa_name (var_map, int);
123 static void assign_vars (var_map);
124 static bool replace_use_variable (var_map, use_operand_p, tree *);
125 static bool replace_def_variable (var_map, def_operand_p, tree *);
126 static void eliminate_virtual_phis (void);
127 static void coalesce_abnormal_edges (var_map, conflict_graph, root_var_p);
128 static void print_exprs (FILE *, const char *, tree, const char *, tree,
130 static void print_exprs_edge (FILE *, edge, const char *, tree, const char *,
134 /* Create a temporary variable based on the type of variable T. Use T's name
141 const char *name = NULL;
144 if (TREE_CODE (t) == SSA_NAME)
145 t = SSA_NAME_VAR (t);
147 gcc_assert (TREE_CODE (t) == VAR_DECL || TREE_CODE (t) == PARM_DECL);
149 type = TREE_TYPE (t);
152 name = IDENTIFIER_POINTER (tmp);
156 tmp = create_tmp_var (type, name);
158 if (DECL_DEBUG_EXPR_IS_FROM (t) && DECL_DEBUG_EXPR (t))
160 SET_DECL_DEBUG_EXPR (tmp, DECL_DEBUG_EXPR (t));
161 DECL_DEBUG_EXPR_IS_FROM (tmp) = 1;
163 else if (!DECL_IGNORED_P (t))
165 SET_DECL_DEBUG_EXPR (tmp, t);
166 DECL_DEBUG_EXPR_IS_FROM (tmp) = 1;
168 DECL_ARTIFICIAL (tmp) = DECL_ARTIFICIAL (t);
169 DECL_IGNORED_P (tmp) = DECL_IGNORED_P (t);
170 add_referenced_var (tmp);
172 /* add_referenced_var will create the annotation and set up some
173 of the flags in the annotation. However, some flags we need to
174 inherit from our original variable. */
175 var_ann (tmp)->symbol_mem_tag = var_ann (t)->symbol_mem_tag;
176 if (is_call_clobbered (t))
177 mark_call_clobbered (tmp, var_ann (t)->escape_mask);
183 /* This helper function fill insert a copy from a constant or variable SRC to
184 variable DEST on edge E. */
187 insert_copy_on_edge (edge e, tree dest, tree src)
191 copy = build2 (GIMPLE_MODIFY_STMT, TREE_TYPE (dest), dest, src);
194 if (TREE_CODE (src) == ADDR_EXPR)
195 src = TREE_OPERAND (src, 0);
196 if (TREE_CODE (src) == VAR_DECL || TREE_CODE (src) == PARM_DECL)
199 if (dump_file && (dump_flags & TDF_DETAILS))
202 "Inserting a copy on edge BB%d->BB%d :",
205 print_generic_expr (dump_file, copy, dump_flags);
206 fprintf (dump_file, "\n");
209 bsi_insert_on_edge (e, copy);
213 /* Create an elimination graph with SIZE nodes and associated data
217 new_elim_graph (int size)
219 elim_graph g = (elim_graph) xmalloc (sizeof (struct _elim_graph));
221 g->nodes = VEC_alloc (tree, heap, 30);
222 g->const_copies = VEC_alloc (tree, heap, 20);
223 g->edge_list = VEC_alloc (int, heap, 20);
224 g->stack = VEC_alloc (int, heap, 30);
226 g->visited = sbitmap_alloc (size);
232 /* Empty elimination graph G. */
235 clear_elim_graph (elim_graph g)
237 VEC_truncate (tree, g->nodes, 0);
238 VEC_truncate (int, g->edge_list, 0);
242 /* Delete elimination graph G. */
245 delete_elim_graph (elim_graph g)
247 sbitmap_free (g->visited);
248 VEC_free (int, heap, g->stack);
249 VEC_free (int, heap, g->edge_list);
250 VEC_free (tree, heap, g->const_copies);
251 VEC_free (tree, heap, g->nodes);
256 /* Return the number of nodes in graph G. */
259 elim_graph_size (elim_graph g)
261 return VEC_length (tree, g->nodes);
265 /* Add NODE to graph G, if it doesn't exist already. */
268 elim_graph_add_node (elim_graph g, tree node)
273 for (x = 0; VEC_iterate (tree, g->nodes, x, t); x++)
276 VEC_safe_push (tree, heap, g->nodes, node);
280 /* Add the edge PRED->SUCC to graph G. */
283 elim_graph_add_edge (elim_graph g, int pred, int succ)
285 VEC_safe_push (int, heap, g->edge_list, pred);
286 VEC_safe_push (int, heap, g->edge_list, succ);
290 /* Remove an edge from graph G for which NODE is the predecessor, and
291 return the successor node. -1 is returned if there is no such edge. */
294 elim_graph_remove_succ_edge (elim_graph g, int node)
298 for (x = 0; x < VEC_length (int, g->edge_list); x += 2)
299 if (VEC_index (int, g->edge_list, x) == node)
301 VEC_replace (int, g->edge_list, x, -1);
302 y = VEC_index (int, g->edge_list, x + 1);
303 VEC_replace (int, g->edge_list, x + 1, -1);
310 /* Find all the nodes in GRAPH which are successors to NODE in the
311 edge list. VAR will hold the partition number found. CODE is the
312 code fragment executed for every node found. */
314 #define FOR_EACH_ELIM_GRAPH_SUCC(GRAPH, NODE, VAR, CODE) \
318 for (x_ = 0; x_ < VEC_length (int, (GRAPH)->edge_list); x_ += 2) \
320 y_ = VEC_index (int, (GRAPH)->edge_list, x_); \
323 (VAR) = VEC_index (int, (GRAPH)->edge_list, x_ + 1); \
329 /* Find all the nodes which are predecessors of NODE in the edge list for
330 GRAPH. VAR will hold the partition number found. CODE is the
331 code fragment executed for every node found. */
333 #define FOR_EACH_ELIM_GRAPH_PRED(GRAPH, NODE, VAR, CODE) \
337 for (x_ = 0; x_ < VEC_length (int, (GRAPH)->edge_list); x_ += 2) \
339 y_ = VEC_index (int, (GRAPH)->edge_list, x_ + 1); \
342 (VAR) = VEC_index (int, (GRAPH)->edge_list, x_); \
348 /* Add T to elimination graph G. */
351 eliminate_name (elim_graph g, tree T)
353 elim_graph_add_node (g, T);
357 /* Build elimination graph G for basic block BB on incoming PHI edge
361 eliminate_build (elim_graph g, basic_block B)
367 clear_elim_graph (g);
369 for (phi = phi_nodes (B); phi; phi = PHI_CHAIN (phi))
371 T0 = var_to_partition_to_var (g->map, PHI_RESULT (phi));
373 /* Ignore results which are not in partitions. */
377 Ti = PHI_ARG_DEF (phi, g->e->dest_idx);
379 /* If this argument is a constant, or a SSA_NAME which is being
380 left in SSA form, just queue a copy to be emitted on this
382 if (!phi_ssa_name_p (Ti)
383 || (TREE_CODE (Ti) == SSA_NAME
384 && var_to_partition (g->map, Ti) == NO_PARTITION))
386 /* Save constant copies until all other copies have been emitted
388 VEC_safe_push (tree, heap, g->const_copies, T0);
389 VEC_safe_push (tree, heap, g->const_copies, Ti);
393 Ti = var_to_partition_to_var (g->map, Ti);
396 eliminate_name (g, T0);
397 eliminate_name (g, Ti);
398 p0 = var_to_partition (g->map, T0);
399 pi = var_to_partition (g->map, Ti);
400 elim_graph_add_edge (g, p0, pi);
407 /* Push successors of T onto the elimination stack for G. */
410 elim_forward (elim_graph g, int T)
413 SET_BIT (g->visited, T);
414 FOR_EACH_ELIM_GRAPH_SUCC (g, T, S,
416 if (!TEST_BIT (g->visited, S))
419 VEC_safe_push (int, heap, g->stack, T);
423 /* Return 1 if there unvisited predecessors of T in graph G. */
426 elim_unvisited_predecessor (elim_graph g, int T)
429 FOR_EACH_ELIM_GRAPH_PRED (g, T, P,
431 if (!TEST_BIT (g->visited, P))
437 /* Process predecessors first, and insert a copy. */
440 elim_backward (elim_graph g, int T)
443 SET_BIT (g->visited, T);
444 FOR_EACH_ELIM_GRAPH_PRED (g, T, P,
446 if (!TEST_BIT (g->visited, P))
448 elim_backward (g, P);
449 insert_copy_on_edge (g->e,
450 partition_to_var (g->map, P),
451 partition_to_var (g->map, T));
456 /* Insert required copies for T in graph G. Check for a strongly connected
457 region, and create a temporary to break the cycle if one is found. */
460 elim_create (elim_graph g, int T)
465 if (elim_unvisited_predecessor (g, T))
467 U = create_temp (partition_to_var (g->map, T));
468 insert_copy_on_edge (g->e, U, partition_to_var (g->map, T));
469 FOR_EACH_ELIM_GRAPH_PRED (g, T, P,
471 if (!TEST_BIT (g->visited, P))
473 elim_backward (g, P);
474 insert_copy_on_edge (g->e, partition_to_var (g->map, P), U);
480 S = elim_graph_remove_succ_edge (g, T);
483 SET_BIT (g->visited, T);
484 insert_copy_on_edge (g->e,
485 partition_to_var (g->map, T),
486 partition_to_var (g->map, S));
492 /* Eliminate all the phi nodes on edge E in graph G. */
495 eliminate_phi (edge e, elim_graph g)
498 basic_block B = e->dest;
500 gcc_assert (VEC_length (tree, g->const_copies) == 0);
502 /* Abnormal edges already have everything coalesced. */
503 if (e->flags & EDGE_ABNORMAL)
508 eliminate_build (g, B);
510 if (elim_graph_size (g) != 0)
514 sbitmap_zero (g->visited);
515 VEC_truncate (int, g->stack, 0);
517 for (x = 0; VEC_iterate (tree, g->nodes, x, var); x++)
519 int p = var_to_partition (g->map, var);
520 if (!TEST_BIT (g->visited, p))
524 sbitmap_zero (g->visited);
525 while (VEC_length (int, g->stack) > 0)
527 x = VEC_pop (int, g->stack);
528 if (!TEST_BIT (g->visited, x))
533 /* If there are any pending constant copies, issue them now. */
534 while (VEC_length (tree, g->const_copies) > 0)
537 src = VEC_pop (tree, g->const_copies);
538 dest = VEC_pop (tree, g->const_copies);
539 insert_copy_on_edge (e, dest, src);
544 /* Shortcut routine to print messages to file F of the form:
545 "STR1 EXPR1 STR2 EXPR2 STR3." */
548 print_exprs (FILE *f, const char *str1, tree expr1, const char *str2,
549 tree expr2, const char *str3)
551 fprintf (f, "%s", str1);
552 print_generic_expr (f, expr1, TDF_SLIM);
553 fprintf (f, "%s", str2);
554 print_generic_expr (f, expr2, TDF_SLIM);
555 fprintf (f, "%s", str3);
559 /* Shortcut routine to print abnormal edge messages to file F of the form:
560 "STR1 EXPR1 STR2 EXPR2 across edge E. */
563 print_exprs_edge (FILE *f, edge e, const char *str1, tree expr1,
564 const char *str2, tree expr2)
566 print_exprs (f, str1, expr1, str2, expr2, " across an abnormal edge");
567 fprintf (f, " from BB%d->BB%d\n", e->src->index,
572 /* Coalesce partitions in MAP which are live across abnormal edges in GRAPH.
573 RV is the root variable groupings of the partitions in MAP. Since code
574 cannot be inserted on these edges, failure to coalesce something across
575 an abnormal edge is an error. */
578 coalesce_abnormal_edges (var_map map, conflict_graph graph, root_var_p rv)
586 /* Code cannot be inserted on abnormal edges. Look for all abnormal
587 edges, and coalesce any PHI results with their arguments across
591 FOR_EACH_EDGE (e, ei, bb->succs)
592 if (e->dest != EXIT_BLOCK_PTR && e->flags & EDGE_ABNORMAL)
593 for (phi = phi_nodes (e->dest); phi; phi = PHI_CHAIN (phi))
595 /* Visit each PHI on the destination side of this abnormal
596 edge, and attempt to coalesce the argument with the result. */
597 var = PHI_RESULT (phi);
598 x = var_to_partition (map, var);
600 /* Ignore results which are not relevant. */
601 if (x == NO_PARTITION)
604 tmp = PHI_ARG_DEF (phi, e->dest_idx);
605 #ifdef ENABLE_CHECKING
606 if (!phi_ssa_name_p (tmp))
608 print_exprs_edge (stderr, e,
609 "\nConstant argument in PHI. Can't insert :",
611 internal_error ("SSA corruption");
614 gcc_assert (phi_ssa_name_p (tmp));
616 y = var_to_partition (map, tmp);
617 gcc_assert (x != NO_PARTITION);
618 gcc_assert (y != NO_PARTITION);
619 #ifdef ENABLE_CHECKING
620 if (root_var_find (rv, x) != root_var_find (rv, y))
622 print_exprs_edge (stderr, e, "\nDifferent root vars: ",
623 root_var (rv, root_var_find (rv, x)),
625 root_var (rv, root_var_find (rv, y)));
626 internal_error ("SSA corruption");
629 gcc_assert (root_var_find (rv, x) == root_var_find (rv, y));
634 #ifdef ENABLE_CHECKING
635 if (conflict_graph_conflict_p (graph, x, y))
637 print_exprs_edge (stderr, e, "\n Conflict ",
638 partition_to_var (map, x),
639 " and ", partition_to_var (map, y));
640 internal_error ("SSA corruption");
643 gcc_assert (!conflict_graph_conflict_p (graph, x, y));
646 /* Now map the partitions back to their real variables. */
647 var = partition_to_var (map, x);
648 tmp = partition_to_var (map, y);
649 if (dump_file && (dump_flags & TDF_DETAILS))
651 print_exprs_edge (dump_file, e,
652 "ABNORMAL: Coalescing ",
655 z = var_union (map, var, tmp);
656 #ifdef ENABLE_CHECKING
657 if (z == NO_PARTITION)
659 print_exprs_edge (stderr, e, "\nUnable to coalesce",
660 partition_to_var (map, x), " and ",
661 partition_to_var (map, y));
662 internal_error ("SSA corruption");
665 gcc_assert (z != NO_PARTITION);
667 gcc_assert (z == x || z == y);
669 conflict_graph_merge_regs (graph, x, y);
671 conflict_graph_merge_regs (graph, y, x);
676 /* Coalesce potential copies via PHI arguments. */
679 coalesce_phi_operands (var_map map, coalesce_list_p cl)
686 for (phi = phi_nodes (bb); phi; phi = PHI_CHAIN (phi))
688 tree res = PHI_RESULT (phi);
689 int p = var_to_partition (map, res);
692 if (p == NO_PARTITION)
695 for (x = 0; x < PHI_NUM_ARGS (phi); x++)
697 tree arg = PHI_ARG_DEF (phi, x);
700 if (TREE_CODE (arg) != SSA_NAME)
702 if (SSA_NAME_VAR (res) != SSA_NAME_VAR (arg))
704 p2 = var_to_partition (map, PHI_ARG_DEF (phi, x));
705 if (p2 != NO_PARTITION)
707 edge e = PHI_ARG_EDGE (phi, x);
708 add_coalesce (cl, p, p2,
709 coalesce_cost (EDGE_FREQUENCY (e),
711 EDGE_CRITICAL_P (e)));
718 /* Coalesce all the result decls together. */
721 coalesce_result_decls (var_map map, coalesce_list_p cl)
726 for (i = x = 0; x < num_var_partitions (map); x++)
728 tree p = partition_to_var (map, x);
729 if (TREE_CODE (SSA_NAME_VAR (p)) == RESULT_DECL)
731 if (var == NULL_TREE)
737 add_coalesce (cl, i, x,
738 coalesce_cost (EXIT_BLOCK_PTR->frequency,
739 maybe_hot_bb_p (EXIT_BLOCK_PTR),
745 /* Coalesce matching constraints in asms. */
748 coalesce_asm_operands (var_map map, coalesce_list_p cl)
754 block_stmt_iterator bsi;
755 for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
757 tree stmt = bsi_stmt (bsi);
758 unsigned long noutputs, i;
761 if (TREE_CODE (stmt) != ASM_EXPR)
764 noutputs = list_length (ASM_OUTPUTS (stmt));
765 outputs = (tree *) alloca (noutputs * sizeof (tree));
766 for (i = 0, link = ASM_OUTPUTS (stmt); link;
767 ++i, link = TREE_CHAIN (link))
768 outputs[i] = TREE_VALUE (link);
770 for (link = ASM_INPUTS (stmt); link; link = TREE_CHAIN (link))
772 const char *constraint
773 = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (link)));
774 tree input = TREE_VALUE (link);
779 if (TREE_CODE (input) != SSA_NAME && !DECL_P (input))
782 match = strtoul (constraint, &end, 10);
783 if (match >= noutputs || end == constraint)
786 if (TREE_CODE (outputs[match]) != SSA_NAME
787 && !DECL_P (outputs[match]))
790 p1 = var_to_partition (map, outputs[match]);
791 if (p1 == NO_PARTITION)
793 p2 = var_to_partition (map, input);
794 if (p2 == NO_PARTITION)
797 add_coalesce (cl, p1, p2, coalesce_cost (REG_BR_PROB_BASE,
805 /* Reduce the number of live ranges in MAP. Live range information is
806 returned if FLAGS indicates that we are combining temporaries, otherwise
807 NULL is returned. The only partitions which are associated with actual
808 variables at this point are those which are forced to be coalesced for
809 various reason. (live on entry, live across abnormal edges, etc.). */
811 static tree_live_info_p
812 coalesce_ssa_name (var_map map, int flags)
817 tree_live_info_p liveinfo;
818 conflict_graph graph;
819 coalesce_list_p cl = NULL;
820 sbitmap_iterator sbi;
822 if (num_var_partitions (map) <= 1)
825 liveinfo = calculate_live_ranges (map);
826 rv = root_var_init (map);
828 /* Remove single element variable from the list. */
829 root_var_compact (rv);
831 cl = create_coalesce_list (map);
833 coalesce_phi_operands (map, cl);
834 coalesce_result_decls (map, cl);
835 coalesce_asm_operands (map, cl);
837 /* Build a conflict graph. */
838 graph = build_tree_conflict_graph (liveinfo, rv, cl);
842 if (dump_file && (dump_flags & TDF_DETAILS))
844 fprintf (dump_file, "Before sorting:\n");
845 dump_coalesce_list (dump_file, cl);
848 sort_coalesce_list (cl);
850 if (dump_file && (dump_flags & TDF_DETAILS))
852 fprintf (dump_file, "\nAfter sorting:\n");
853 dump_coalesce_list (dump_file, cl);
857 /* Put the single element variables back in. */
858 root_var_decompact (rv);
860 /* First, coalesce all live on entry variables to their root variable.
861 This will ensure the first use is coming from the correct location. */
863 num = num_var_partitions (map);
864 live = sbitmap_alloc (num);
867 /* Set 'live' vector to indicate live on entry partitions. */
868 for (x = 0 ; x < num; x++)
870 tree var = partition_to_var (map, x);
871 if (gimple_default_def (cfun, SSA_NAME_VAR (var)) == var)
875 delete_tree_live_info (liveinfo);
878 /* Assign root variable as partition representative for each live on entry
880 EXECUTE_IF_SET_IN_SBITMAP (live, 0, x, sbi)
882 tree var = root_var (rv, root_var_find (rv, x));
883 var_ann_t ann = var_ann (var);
884 /* If these aren't already coalesced... */
885 if (partition_to_var (map, x) != var)
887 /* This root variable should have not already been assigned
888 to another partition which is not coalesced with this one. */
889 gcc_assert (!ann->out_of_ssa_tag);
891 if (dump_file && (dump_flags & TDF_DETAILS))
893 print_exprs (dump_file, "Must coalesce ",
894 partition_to_var (map, x),
895 " with the root variable ", var, ".\n");
898 change_partition_var (map, var, x);
904 /* Coalesce partitions live across abnormal edges. */
905 coalesce_abnormal_edges (map, graph, rv);
907 if (dump_file && (dump_flags & TDF_DETAILS))
908 dump_var_map (dump_file, map);
910 /* Coalesce partitions. */
911 coalesce_tpa_members (rv, graph, map, cl,
912 ((dump_flags & TDF_DETAILS) ? dump_file
915 if (flags & SSANORM_COALESCE_PARTITIONS)
916 coalesce_tpa_members (rv, graph, map, NULL,
917 ((dump_flags & TDF_DETAILS) ? dump_file
920 delete_coalesce_list (cl);
921 root_var_delete (rv);
922 conflict_graph_delete (graph);
928 /* Take the ssa-name var_map MAP, and assign real variables to each
932 assign_vars (var_map map)
939 rv = root_var_init (map);
943 /* Coalescing may already have forced some partitions to their root
944 variable. Find these and tag them. */
946 num = num_var_partitions (map);
947 for (x = 0; x < num; x++)
949 var = partition_to_var (map, x);
950 if (TREE_CODE (var) != SSA_NAME)
952 /* Coalescing will already have verified that more than one
953 partition doesn't have the same root variable. Simply marked
954 the variable as assigned. */
956 ann->out_of_ssa_tag = 1;
957 if (dump_file && (dump_flags & TDF_DETAILS))
959 fprintf (dump_file, "partition %d has variable ", x);
960 print_generic_expr (dump_file, var, TDF_SLIM);
961 fprintf (dump_file, " assigned to it.\n");
967 num = root_var_num (rv);
968 for (x = 0; x < num; x++)
970 var = root_var (rv, x);
972 for (i = root_var_first_partition (rv, x);
974 i = root_var_next_partition (rv, i))
976 t = partition_to_var (map, i);
978 if (t == var || TREE_CODE (t) != SSA_NAME)
981 rep = var_to_partition (map, t);
983 if (!ann->out_of_ssa_tag)
985 if (dump_file && (dump_flags & TDF_DETAILS))
986 print_exprs (dump_file, "", t, " --> ", var, "\n");
987 change_partition_var (map, var, rep);
991 if (dump_file && (dump_flags & TDF_DETAILS))
992 print_exprs (dump_file, "", t, " not coalesced with ", var,
995 var = create_temp (t);
996 change_partition_var (map, var, rep);
999 if (dump_file && (dump_flags & TDF_DETAILS))
1001 fprintf (dump_file, " --> New temp: '");
1002 print_generic_expr (dump_file, var, TDF_SLIM);
1003 fprintf (dump_file, "'\n");
1008 root_var_delete (rv);
1012 /* Replace use operand P with whatever variable it has been rewritten to based
1013 on the partitions in MAP. EXPR is an optional expression vector over SSA
1014 versions which is used to replace P with an expression instead of a variable.
1015 If the stmt is changed, return true. */
1018 replace_use_variable (var_map map, use_operand_p p, tree *expr)
1021 tree var = USE_FROM_PTR (p);
1023 /* Check if we are replacing this variable with an expression. */
1026 int version = SSA_NAME_VERSION (var);
1029 tree new_expr = GIMPLE_STMT_OPERAND (expr[version], 1);
1030 SET_USE (p, new_expr);
1031 /* Clear the stmt's RHS, or GC might bite us. */
1032 GIMPLE_STMT_OPERAND (expr[version], 1) = NULL_TREE;
1037 new_var = var_to_partition_to_var (map, var);
1040 SET_USE (p, new_var);
1041 set_is_used (new_var);
1048 /* Replace def operand DEF_P with whatever variable it has been rewritten to
1049 based on the partitions in MAP. EXPR is an optional expression vector over
1050 SSA versions which is used to replace DEF_P with an expression instead of a
1051 variable. If the stmt is changed, return true. */
1054 replace_def_variable (var_map map, def_operand_p def_p, tree *expr)
1057 tree var = DEF_FROM_PTR (def_p);
1059 /* Check if we are replacing this variable with an expression. */
1062 int version = SSA_NAME_VERSION (var);
1065 tree new_expr = TREE_OPERAND (expr[version], 1);
1066 SET_DEF (def_p, new_expr);
1067 /* Clear the stmt's RHS, or GC might bite us. */
1068 TREE_OPERAND (expr[version], 1) = NULL_TREE;
1073 new_var = var_to_partition_to_var (map, var);
1076 SET_DEF (def_p, new_var);
1077 set_is_used (new_var);
1084 /* Remove any PHI node which is a virtual PHI. */
1087 eliminate_virtual_phis (void)
1094 for (phi = phi_nodes (bb); phi; phi = next)
1096 next = PHI_CHAIN (phi);
1097 if (!is_gimple_reg (SSA_NAME_VAR (PHI_RESULT (phi))))
1099 #ifdef ENABLE_CHECKING
1101 /* There should be no arguments of this PHI which are in
1102 the partition list, or we get incorrect results. */
1103 for (i = 0; i < PHI_NUM_ARGS (phi); i++)
1105 tree arg = PHI_ARG_DEF (phi, i);
1106 if (TREE_CODE (arg) == SSA_NAME
1107 && is_gimple_reg (SSA_NAME_VAR (arg)))
1109 fprintf (stderr, "Argument of PHI is not virtual (");
1110 print_generic_expr (stderr, arg, TDF_SLIM);
1111 fprintf (stderr, "), but the result is :");
1112 print_generic_stmt (stderr, phi, TDF_SLIM);
1113 internal_error ("SSA corruption");
1117 remove_phi_node (phi, NULL_TREE);
1124 /* This function will rewrite the current program using the variable mapping
1125 found in MAP. If the replacement vector VALUES is provided, any
1126 occurrences of partitions with non-null entries in the vector will be
1127 replaced with the expression in the vector instead of its mapped
1131 rewrite_trees (var_map map, tree *values)
1135 block_stmt_iterator si;
1140 #ifdef ENABLE_CHECKING
1141 /* Search for PHIs where the destination has no partition, but one
1142 or more arguments has a partition. This should not happen and can
1143 create incorrect code. */
1148 for (phi = phi_nodes (bb); phi; phi = PHI_CHAIN (phi))
1150 tree T0 = var_to_partition_to_var (map, PHI_RESULT (phi));
1152 if (T0 == NULL_TREE)
1156 for (i = 0; i < PHI_NUM_ARGS (phi); i++)
1158 tree arg = PHI_ARG_DEF (phi, i);
1160 if (TREE_CODE (arg) == SSA_NAME
1161 && var_to_partition (map, arg) != NO_PARTITION)
1163 fprintf (stderr, "Argument of PHI is in a partition :(");
1164 print_generic_expr (stderr, arg, TDF_SLIM);
1165 fprintf (stderr, "), but the result is not :");
1166 print_generic_stmt (stderr, phi, TDF_SLIM);
1167 internal_error ("SSA corruption");
1175 /* Replace PHI nodes with any required copies. */
1176 g = new_elim_graph (map->num_partitions);
1180 for (si = bsi_start (bb); !bsi_end_p (si); )
1182 tree stmt = bsi_stmt (si);
1183 use_operand_p use_p, copy_use_p;
1184 def_operand_p def_p;
1185 bool remove = false, is_copy = false;
1190 ann = stmt_ann (stmt);
1193 if (TREE_CODE (stmt) == GIMPLE_MODIFY_STMT
1194 && (TREE_CODE (GIMPLE_STMT_OPERAND (stmt, 1)) == SSA_NAME))
1197 copy_use_p = NULL_USE_OPERAND_P;
1198 FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_USE)
1200 if (replace_use_variable (map, use_p, values))
1209 def_p = SINGLE_SSA_DEF_OPERAND (stmt, SSA_OP_DEF);
1213 /* Mark this stmt for removal if it is the list of replaceable
1215 if (values && values[SSA_NAME_VERSION (DEF_FROM_PTR (def_p))])
1219 if (replace_def_variable (map, def_p, NULL))
1221 /* If both SSA_NAMEs coalesce to the same variable,
1222 mark the now redundant copy for removal. */
1225 gcc_assert (copy_use_p != NULL_USE_OPERAND_P);
1226 if (DEF_FROM_PTR (def_p) == USE_FROM_PTR (copy_use_p))
1232 FOR_EACH_SSA_DEF_OPERAND (def_p, stmt, iter, SSA_OP_DEF)
1233 if (replace_def_variable (map, def_p, NULL))
1236 /* Remove any stmts marked for removal. */
1238 bsi_remove (&si, true);
1243 phi = phi_nodes (bb);
1247 FOR_EACH_EDGE (e, ei, bb->preds)
1248 eliminate_phi (e, g);
1252 delete_elim_graph (g);
1255 /* These are the local work structures used to determine the best place to
1256 insert the copies that were placed on edges by the SSA->normal pass.. */
1257 static VEC(edge,heap) *edge_leader;
1258 static VEC(tree,heap) *stmt_list;
1259 static bitmap leader_has_match = NULL;
1260 static edge leader_match = NULL;
1263 /* Pass this function to make_forwarder_block so that all the edges with
1264 matching PENDING_STMT lists to 'curr_stmt_list' get redirected. */
1266 same_stmt_list_p (edge e)
1268 return (e->aux == (PTR) leader_match) ? true : false;
1272 /* Return TRUE if S1 and S2 are equivalent copies. */
1274 identical_copies_p (tree s1, tree s2)
1276 #ifdef ENABLE_CHECKING
1277 gcc_assert (TREE_CODE (s1) == GIMPLE_MODIFY_STMT);
1278 gcc_assert (TREE_CODE (s2) == GIMPLE_MODIFY_STMT);
1279 gcc_assert (DECL_P (GIMPLE_STMT_OPERAND (s1, 0)));
1280 gcc_assert (DECL_P (GIMPLE_STMT_OPERAND (s2, 0)));
1283 if (GIMPLE_STMT_OPERAND (s1, 0) != GIMPLE_STMT_OPERAND (s2, 0))
1286 s1 = GIMPLE_STMT_OPERAND (s1, 1);
1287 s2 = GIMPLE_STMT_OPERAND (s2, 1);
1296 /* Compare the PENDING_STMT list for two edges, and return true if the lists
1297 contain the same sequence of copies. */
1300 identical_stmt_lists_p (edge e1, edge e2)
1302 tree t1 = PENDING_STMT (e1);
1303 tree t2 = PENDING_STMT (e2);
1304 tree_stmt_iterator tsi1, tsi2;
1306 gcc_assert (TREE_CODE (t1) == STATEMENT_LIST);
1307 gcc_assert (TREE_CODE (t2) == STATEMENT_LIST);
1309 for (tsi1 = tsi_start (t1), tsi2 = tsi_start (t2);
1310 !tsi_end_p (tsi1) && !tsi_end_p (tsi2);
1311 tsi_next (&tsi1), tsi_next (&tsi2))
1313 if (!identical_copies_p (tsi_stmt (tsi1), tsi_stmt (tsi2)))
1317 if (!tsi_end_p (tsi1) || ! tsi_end_p (tsi2))
1324 /* Allocate data structures used in analyze_edges_for_bb. */
1327 init_analyze_edges_for_bb (void)
1329 edge_leader = VEC_alloc (edge, heap, 25);
1330 stmt_list = VEC_alloc (tree, heap, 25);
1331 leader_has_match = BITMAP_ALLOC (NULL);
1335 /* Free data structures used in analyze_edges_for_bb. */
1338 fini_analyze_edges_for_bb (void)
1340 VEC_free (edge, heap, edge_leader);
1341 VEC_free (tree, heap, stmt_list);
1342 BITMAP_FREE (leader_has_match);
1346 /* Look at all the incoming edges to block BB, and decide where the best place
1347 to insert the stmts on each edge are, and perform those insertions. */
1350 analyze_edges_for_bb (basic_block bb)
1356 bool have_opportunity;
1357 block_stmt_iterator bsi;
1359 edge single_edge = NULL;
1365 /* Blocks which contain at least one abnormal edge cannot use
1366 make_forwarder_block. Look for these blocks, and commit any PENDING_STMTs
1367 found on edges in these block. */
1368 have_opportunity = true;
1369 FOR_EACH_EDGE (e, ei, bb->preds)
1370 if (e->flags & EDGE_ABNORMAL)
1372 have_opportunity = false;
1376 if (!have_opportunity)
1378 FOR_EACH_EDGE (e, ei, bb->preds)
1379 if (PENDING_STMT (e))
1380 bsi_commit_one_edge_insert (e, NULL);
1383 /* Find out how many edges there are with interesting pending stmts on them.
1384 Commit the stmts on edges we are not interested in. */
1385 FOR_EACH_EDGE (e, ei, bb->preds)
1387 if (PENDING_STMT (e))
1389 gcc_assert (!(e->flags & EDGE_ABNORMAL));
1390 if (e->flags & EDGE_FALLTHRU)
1392 bsi = bsi_start (e->src);
1393 if (!bsi_end_p (bsi))
1395 stmt = bsi_stmt (bsi);
1397 gcc_assert (stmt != NULL_TREE);
1398 is_label = (TREE_CODE (stmt) == LABEL_EXPR);
1399 /* Punt if it has non-label stmts, or isn't local. */
1400 if (!is_label || DECL_NONLOCAL (TREE_OPERAND (stmt, 0))
1401 || !bsi_end_p (bsi))
1403 bsi_commit_one_edge_insert (e, NULL);
1413 /* If there aren't at least 2 edges, no sharing will happen. */
1417 bsi_commit_one_edge_insert (single_edge, NULL);
1421 /* Ensure that we have empty worklists. */
1422 #ifdef ENABLE_CHECKING
1423 gcc_assert (VEC_length (edge, edge_leader) == 0);
1424 gcc_assert (VEC_length (tree, stmt_list) == 0);
1425 gcc_assert (bitmap_empty_p (leader_has_match));
1428 /* Find the "leader" block for each set of unique stmt lists. Preference is
1429 given to FALLTHRU blocks since they would need a GOTO to arrive at another
1430 block. The leader edge destination is the block which all the other edges
1431 with the same stmt list will be redirected to. */
1432 have_opportunity = false;
1433 FOR_EACH_EDGE (e, ei, bb->preds)
1435 if (PENDING_STMT (e))
1439 /* Look for the same stmt list in edge leaders list. */
1440 for (x = 0; VEC_iterate (edge, edge_leader, x, leader); x++)
1442 if (identical_stmt_lists_p (leader, e))
1444 /* Give this edge the same stmt list pointer. */
1445 PENDING_STMT (e) = NULL;
1447 bitmap_set_bit (leader_has_match, x);
1448 have_opportunity = found = true;
1453 /* If no similar stmt list, add this edge to the leader list. */
1456 VEC_safe_push (edge, heap, edge_leader, e);
1457 VEC_safe_push (tree, heap, stmt_list, PENDING_STMT (e));
1462 /* If there are no similar lists, just issue the stmts. */
1463 if (!have_opportunity)
1465 for (x = 0; VEC_iterate (edge, edge_leader, x, leader); x++)
1466 bsi_commit_one_edge_insert (leader, NULL);
1467 VEC_truncate (edge, edge_leader, 0);
1468 VEC_truncate (tree, stmt_list, 0);
1469 bitmap_clear (leader_has_match);
1475 fprintf (dump_file, "\nOpportunities in BB %d for stmt/block reduction:\n",
1479 /* For each common list, create a forwarding block and issue the stmt's
1481 for (x = 0; VEC_iterate (edge, edge_leader, x, leader); x++)
1482 if (bitmap_bit_p (leader_has_match, x))
1485 block_stmt_iterator bsi;
1486 tree curr_stmt_list;
1488 leader_match = leader;
1490 /* The tree_* cfg manipulation routines use the PENDING_EDGE field
1491 for various PHI manipulations, so it gets cleared when calls are
1492 made to make_forwarder_block(). So make sure the edge is clear,
1493 and use the saved stmt list. */
1494 PENDING_STMT (leader) = NULL;
1495 leader->aux = leader;
1496 curr_stmt_list = VEC_index (tree, stmt_list, x);
1498 new_edge = make_forwarder_block (leader->dest, same_stmt_list_p,
1500 bb = new_edge->dest;
1503 fprintf (dump_file, "Splitting BB %d for Common stmt list. ",
1504 leader->dest->index);
1505 fprintf (dump_file, "Original block is now BB%d.\n", bb->index);
1506 print_generic_stmt (dump_file, curr_stmt_list, TDF_VOPS);
1509 FOR_EACH_EDGE (e, ei, new_edge->src->preds)
1513 fprintf (dump_file, " Edge (%d->%d) lands here.\n",
1514 e->src->index, e->dest->index);
1517 bsi = bsi_last (leader->dest);
1518 bsi_insert_after (&bsi, curr_stmt_list, BSI_NEW_STMT);
1520 leader_match = NULL;
1521 /* We should never get a new block now. */
1525 PENDING_STMT (leader) = VEC_index (tree, stmt_list, x);
1526 bsi_commit_one_edge_insert (leader, NULL);
1530 /* Clear the working data structures. */
1531 VEC_truncate (edge, edge_leader, 0);
1532 VEC_truncate (tree, stmt_list, 0);
1533 bitmap_clear (leader_has_match);
1537 /* This function will analyze the insertions which were performed on edges,
1538 and decide whether they should be left on that edge, or whether it is more
1539 efficient to emit some subset of them in a single block. All stmts are
1540 inserted somewhere. */
1543 perform_edge_inserts (void)
1548 fprintf(dump_file, "Analyzing Edge Insertions.\n");
1550 /* analyze_edges_for_bb calls make_forwarder_block, which tries to
1551 incrementally update the dominator information. Since we don't
1552 need dominator information after this pass, go ahead and free the
1553 dominator information. */
1554 free_dominance_info (CDI_DOMINATORS);
1555 free_dominance_info (CDI_POST_DOMINATORS);
1557 /* Allocate data structures used in analyze_edges_for_bb. */
1558 init_analyze_edges_for_bb ();
1561 analyze_edges_for_bb (bb);
1563 analyze_edges_for_bb (EXIT_BLOCK_PTR);
1565 /* Free data structures used in analyze_edges_for_bb. */
1566 fini_analyze_edges_for_bb ();
1568 #ifdef ENABLE_CHECKING
1574 FOR_EACH_EDGE (e, ei, bb->preds)
1576 if (PENDING_STMT (e))
1577 error (" Pending stmts not issued on PRED edge (%d, %d)\n",
1578 e->src->index, e->dest->index);
1580 FOR_EACH_EDGE (e, ei, bb->succs)
1582 if (PENDING_STMT (e))
1583 error (" Pending stmts not issued on SUCC edge (%d, %d)\n",
1584 e->src->index, e->dest->index);
1587 FOR_EACH_EDGE (e, ei, ENTRY_BLOCK_PTR->succs)
1589 if (PENDING_STMT (e))
1590 error (" Pending stmts not issued on ENTRY edge (%d, %d)\n",
1591 e->src->index, e->dest->index);
1593 FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds)
1595 if (PENDING_STMT (e))
1596 error (" Pending stmts not issued on EXIT edge (%d, %d)\n",
1597 e->src->index, e->dest->index);
1604 /* Remove the variables specified in MAP from SSA form. FLAGS indicate what
1605 options should be used. */
1608 remove_ssa_form (var_map map, int flags)
1610 tree_live_info_p liveinfo;
1613 tree *values = NULL;
1615 /* If we are not combining temps, don't calculate live ranges for variables
1616 with only one SSA version. */
1617 compact_var_map (map, VARMAP_NO_SINGLE_DEFS);
1619 if (dump_file && (dump_flags & TDF_DETAILS))
1620 dump_var_map (dump_file, map);
1622 liveinfo = coalesce_ssa_name (map, flags);
1624 /* Make sure even single occurrence variables are in the list now. */
1625 compact_var_map (map, VARMAP_NORMAL);
1627 if (dump_file && (dump_flags & TDF_DETAILS))
1629 fprintf (dump_file, "After Coalescing:\n");
1630 dump_var_map (dump_file, map);
1633 if (flags & SSANORM_PERFORM_TER)
1635 values = find_replaceable_exprs (map);
1636 if (values && dump_file && (dump_flags & TDF_DETAILS))
1637 dump_replaceable_exprs (dump_file, values);
1640 /* Assign real variables to the partitions now. */
1643 if (dump_file && (dump_flags & TDF_DETAILS))
1645 fprintf (dump_file, "After Root variable replacement:\n");
1646 dump_var_map (dump_file, map);
1650 delete_tree_live_info (liveinfo);
1652 rewrite_trees (map, values);
1657 /* Remove phi nodes which have been translated back to real variables. */
1660 for (phi = phi_nodes (bb); phi; phi = next)
1662 next = PHI_CHAIN (phi);
1663 remove_phi_node (phi, NULL_TREE);
1667 /* we no longer maintain the SSA operand cache at this point. */
1668 fini_ssa_operands ();
1670 /* If any copies were inserted on edges, analyze and insert them now. */
1671 perform_edge_inserts ();
1674 /* Search every PHI node for arguments associated with backedges which
1675 we can trivially determine will need a copy (the argument is either
1676 not an SSA_NAME or the argument has a different underlying variable
1677 than the PHI result).
1679 Insert a copy from the PHI argument to a new destination at the
1680 end of the block with the backedge to the top of the loop. Update
1681 the PHI argument to reference this new destination. */
1684 insert_backedge_copies (void)
1692 for (phi = phi_nodes (bb); phi; phi = PHI_CHAIN (phi))
1694 tree result = PHI_RESULT (phi);
1698 if (!is_gimple_reg (result))
1701 result_var = SSA_NAME_VAR (result);
1702 for (i = 0; i < PHI_NUM_ARGS (phi); i++)
1704 tree arg = PHI_ARG_DEF (phi, i);
1705 edge e = PHI_ARG_EDGE (phi, i);
1707 /* If the argument is not an SSA_NAME, then we will
1708 need a constant initialization. If the argument is
1709 an SSA_NAME with a different underlying variable and
1710 we are not combining temporaries, then we will
1711 need a copy statement. */
1712 if ((e->flags & EDGE_DFS_BACK)
1713 && (TREE_CODE (arg) != SSA_NAME
1714 || SSA_NAME_VAR (arg) != result_var))
1716 tree stmt, name, last = NULL;
1717 block_stmt_iterator bsi;
1719 bsi = bsi_last (PHI_ARG_EDGE (phi, i)->src);
1720 if (!bsi_end_p (bsi))
1721 last = bsi_stmt (bsi);
1723 /* In theory the only way we ought to get back to the
1724 start of a loop should be with a COND_EXPR or GOTO_EXPR.
1725 However, better safe than sorry.
1727 If the block ends with a control statement or
1728 something that might throw, then we have to
1729 insert this assignment before the last
1730 statement. Else insert it after the last statement. */
1731 if (last && stmt_ends_bb_p (last))
1733 /* If the last statement in the block is the definition
1734 site of the PHI argument, then we can't insert
1735 anything after it. */
1736 if (TREE_CODE (arg) == SSA_NAME
1737 && SSA_NAME_DEF_STMT (arg) == last)
1741 /* Create a new instance of the underlying
1742 variable of the PHI result. */
1743 stmt = build2 (GIMPLE_MODIFY_STMT, TREE_TYPE (result_var),
1744 NULL_TREE, PHI_ARG_DEF (phi, i));
1745 name = make_ssa_name (result_var, stmt);
1746 GIMPLE_STMT_OPERAND (stmt, 0) = name;
1748 /* Insert the new statement into the block and update
1750 if (last && stmt_ends_bb_p (last))
1751 bsi_insert_before (&bsi, stmt, BSI_NEW_STMT);
1753 bsi_insert_after (&bsi, stmt, BSI_NEW_STMT);
1754 SET_PHI_ARG_DEF (phi, i, name);
1761 /* Take the current function out of SSA form, as described in
1762 R. Morgan, ``Building an Optimizing Compiler'',
1763 Butterworth-Heinemann, Boston, MA, 1998. pp 176-186. */
1766 rewrite_out_of_ssa (void)
1771 /* If elimination of a PHI requires inserting a copy on a backedge,
1772 then we will have to split the backedge which has numerous
1773 undesirable performance effects.
1775 A significant number of such cases can be handled here by inserting
1776 copies into the loop itself. */
1777 insert_backedge_copies ();
1779 if (!flag_tree_live_range_split)
1780 ssa_flags |= SSANORM_COALESCE_PARTITIONS;
1782 eliminate_virtual_phis ();
1784 if (dump_file && (dump_flags & TDF_DETAILS))
1785 dump_tree_cfg (dump_file, dump_flags & ~TDF_DETAILS);
1787 map = create_ssa_var_map ();
1789 if (flag_tree_ter && !flag_mudflap)
1790 ssa_flags |= SSANORM_PERFORM_TER;
1792 remove_ssa_form (map, ssa_flags);
1794 if (dump_file && (dump_flags & TDF_DETAILS))
1795 dump_tree_cfg (dump_file, dump_flags & ~TDF_DETAILS);
1797 /* Flush out flow graph and SSA data. */
1798 delete_var_map (map);
1800 cfun->gimple_df->in_ssa_p = false;
1805 /* Define the parameters of the out of SSA pass. */
1807 struct tree_opt_pass pass_del_ssa =
1809 "optimized", /* name */
1811 rewrite_out_of_ssa, /* execute */
1814 0, /* static_pass_number */
1815 TV_TREE_SSA_TO_NORMAL, /* tv_id */
1816 PROP_cfg | PROP_ssa | PROP_alias, /* properties_required */
1817 0, /* properties_provided */
1818 /* ??? If TER is enabled, we also kill gimple. */
1819 PROP_ssa, /* properties_destroyed */
1820 TODO_verify_ssa | TODO_verify_flow
1821 | TODO_verify_stmts, /* todo_flags_start */
1824 | TODO_remove_unused_locals, /* todo_flags_finish */