1 /* Liveness for SSA trees.
2 Copyright (C) 2003, 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"
27 #include "diagnostic.h"
29 #include "tree-flow.h"
30 #include "tree-dump.h"
31 #include "tree-ssa-live.h"
34 #ifdef ENABLE_CHECKING
35 static void verify_live_on_entry (tree_live_info_p
);
39 /* VARMAP maintains a mapping from SSA version number to real variables.
41 All SSA_NAMES are divided into partitions. Initially each ssa_name is the
42 only member of it's own partition. Coalescing will attempt to group any
43 ssa_names which occur in a copy or in a PHI node into the same partition.
45 At the end of out-of-ssa, each partition becomes a "real" variable and is
46 rewritten as a compiler variable.
48 The var_map datat structure is used to manage these partitions. It allows
49 partitions to be combined, and determines which partition belongs to what
50 ssa_name or variable, and vice versa. */
53 /* This routine will initialize the basevar fields of MAP. */
56 var_map_base_init (var_map map
)
63 num_part
= num_var_partitions (map
);
65 /* If a base table already exists, clear it, otherwise create it. */
66 if (map
->partition_to_base_index
!= NULL
)
68 free (map
->partition_to_base_index
);
69 VEC_truncate (tree
, map
->basevars
, 0);
72 map
->basevars
= VEC_alloc (tree
, heap
, MAX (40, (num_part
/ 10)));
74 map
->partition_to_base_index
= (int *) xmalloc (sizeof (int) * num_part
);
76 /* Build the base variable list, and point partitions at their bases. */
77 for (x
= 0; x
< num_part
; x
++)
79 var
= partition_to_var (map
, x
);
80 if (TREE_CODE (var
) == SSA_NAME
)
81 var
= SSA_NAME_VAR (var
);
83 /* If base variable hasn't been seen, set it up. */
84 if (!ann
->base_var_processed
)
86 ann
->base_var_processed
= 1;
87 VAR_ANN_BASE_INDEX (ann
) = num
++;
88 VEC_safe_push (tree
, heap
, map
->basevars
, var
);
90 map
->partition_to_base_index
[x
] = VAR_ANN_BASE_INDEX (ann
);
93 map
->num_basevars
= num
;
95 /* Now clear the processed bit. */
96 for (x
= 0; x
< num
; x
++)
98 var
= VEC_index (tree
, map
->basevars
, x
);
99 var_ann (var
)->base_var_processed
= 0;
102 #ifdef ENABLE_CHECKING
103 for (x
= 0; x
< num_part
; x
++)
106 var
= SSA_NAME_VAR (partition_to_var (map
, x
));
107 var2
= VEC_index (tree
, map
->basevars
, basevar_index (map
, x
));
108 gcc_assert (var
== var2
);
114 /* Remove the base table in MAP. */
117 var_map_base_fini (var_map map
)
119 /* Free the basevar info if it is present. */
120 if (map
->partition_to_base_index
!= NULL
)
122 VEC_free (tree
, heap
, map
->basevars
);
123 free (map
->partition_to_base_index
);
124 map
->partition_to_base_index
= NULL
;
125 map
->num_basevars
= 0;
128 /* Create a variable partition map of SIZE, initialize and return it. */
131 init_var_map (int size
)
135 map
= (var_map
) xmalloc (sizeof (struct _var_map
));
136 map
->var_partition
= partition_new (size
);
137 map
->partition_to_var
138 = (tree
*)xmalloc (size
* sizeof (tree
));
139 memset (map
->partition_to_var
, 0, size
* sizeof (tree
));
141 map
->partition_to_view
= NULL
;
142 map
->view_to_partition
= NULL
;
143 map
->num_partitions
= size
;
144 map
->partition_size
= size
;
145 map
->num_basevars
= 0;
146 map
->partition_to_base_index
= NULL
;
147 map
->basevars
= NULL
;
152 /* Free memory associated with MAP. */
155 delete_var_map (var_map map
)
157 var_map_base_fini (map
);
158 free (map
->partition_to_var
);
159 partition_delete (map
->var_partition
);
160 if (map
->partition_to_view
)
161 free (map
->partition_to_view
);
162 if (map
->view_to_partition
)
163 free (map
->view_to_partition
);
168 /* This function will combine the partitions in MAP for VAR1 and VAR2. It
169 Returns the partition which represents the new partition. If the two
170 partitions cannot be combined, NO_PARTITION is returned. */
173 var_union (var_map map
, tree var1
, tree var2
)
176 tree root_var
= NULL_TREE
;
177 tree other_var
= NULL_TREE
;
179 /* This is independent of partition_to_view. If partition_to_view is
180 on, then whichever one of these partitions is absorbed will never have a
181 dereference into the partition_to_view array any more. */
183 if (TREE_CODE (var1
) == SSA_NAME
)
184 p1
= partition_find (map
->var_partition
, SSA_NAME_VERSION (var1
));
187 p1
= var_to_partition (map
, var1
);
188 if (map
->view_to_partition
)
189 p1
= map
->view_to_partition
[p1
];
193 if (TREE_CODE (var2
) == SSA_NAME
)
194 p2
= partition_find (map
->var_partition
, SSA_NAME_VERSION (var2
));
197 p2
= var_to_partition (map
, var2
);
198 if (map
->view_to_partition
)
199 p2
= map
->view_to_partition
[p2
];
201 /* If there is no root_var set, or it's not a user variable, set the
202 root_var to this one. */
203 if (!root_var
|| (DECL_P (root_var
) && DECL_IGNORED_P (root_var
)))
205 other_var
= root_var
;
212 gcc_assert (p1
!= NO_PARTITION
);
213 gcc_assert (p2
!= NO_PARTITION
);
218 p3
= partition_union (map
->var_partition
, p1
, p2
);
220 if (map
->partition_to_view
)
221 p3
= map
->partition_to_view
[p3
];
224 change_partition_var (map
, root_var
, p3
);
226 change_partition_var (map
, other_var
, p3
);
232 /* Compress the partition numbers in MAP such that they fall in the range
233 0..(num_partitions-1) instead of wherever they turned out during
234 the partitioning exercise. This removes any references to unused
235 partitions, thereby allowing bitmaps and other vectors to be much
238 This is implemented such that compaction doesn't affect partitioning.
239 Ie., once partitions are created and possibly merged, running one
240 or more different kind of compaction will not affect the partitions
241 themselves. Their index might change, but all the same variables will
242 still be members of the same partition group. This allows work on reduced
243 sets, and no loss of information when a larger set is later desired.
245 In particular, coalescing can work on partitions which have 2 or more
246 definitions, and then 'recompact' later to include all the single
247 definitions for assignment to program variables. */
250 /* Set MAP back to the initial state of having no partition view. Return a
251 bitmap which has a bit set for each partition number which is in use in the
255 partition_view_init (var_map map
)
261 used
= BITMAP_ALLOC (NULL
);
263 /* Already in a view? Abandon the old one. */
264 if (map
->partition_to_view
)
266 free (map
->partition_to_view
);
267 map
->partition_to_view
= NULL
;
269 if (map
->view_to_partition
)
271 free (map
->view_to_partition
);
272 map
->view_to_partition
= NULL
;
275 /* Find out which partitions are actually referenced. */
276 for (x
= 0; x
< map
->partition_size
; x
++)
278 tmp
= partition_find (map
->var_partition
, x
);
279 if (map
->partition_to_var
[tmp
] != NULL_TREE
&& !bitmap_bit_p (used
, tmp
))
280 bitmap_set_bit (used
, tmp
);
283 map
->num_partitions
= map
->partition_size
;
288 /* This routine will finalize the view data for MAP based on the partitions
289 set in SELECTED. This is either the same bitmap returned from
290 partition_view_init, or a trimmed down version if some of those partitions
291 were not desired in this view. SELECTED is freed before returning. */
294 partition_view_fini (var_map map
, bitmap selected
)
297 unsigned count
, i
, x
, limit
;
300 gcc_assert (selected
);
302 count
= bitmap_count_bits (selected
);
303 limit
= map
->partition_size
;
305 /* If its a one-to-one ratio, we don't need any view compaction. */
308 map
->partition_to_view
= (int *)xmalloc (limit
* sizeof (int));
309 memset (map
->partition_to_view
, 0xff, (limit
* sizeof (int)));
310 map
->view_to_partition
= (int *)xmalloc (count
* sizeof (int));
313 /* Give each selected partition an index. */
314 EXECUTE_IF_SET_IN_BITMAP (selected
, 0, x
, bi
)
316 map
->partition_to_view
[x
] = i
;
317 map
->view_to_partition
[i
] = x
;
318 var
= map
->partition_to_var
[x
];
319 /* If any one of the members of a partition is not an SSA_NAME, make
320 sure it is the representative. */
321 if (TREE_CODE (var
) != SSA_NAME
)
322 change_partition_var (map
, var
, i
);
325 gcc_assert (i
== count
);
326 map
->num_partitions
= i
;
329 BITMAP_FREE (selected
);
333 /* Create a partition view which includes all the used partitions in MAP. If
334 WANT_BASES is true, create the base variable map as well. */
337 partition_view_normal (var_map map
, bool want_bases
)
341 used
= partition_view_init (map
);
342 partition_view_fini (map
, used
);
345 var_map_base_init (map
);
347 var_map_base_fini (map
);
351 /* Create a partition view in MAP which includes just partitions which occur in
352 the bitmap ONLY. If WANT_BASES is true, create the base variable map
356 partition_view_bitmap (var_map map
, bitmap only
, bool want_bases
)
359 bitmap new_partitions
= BITMAP_ALLOC (NULL
);
363 used
= partition_view_init (map
);
364 EXECUTE_IF_SET_IN_BITMAP (only
, 0, x
, bi
)
366 p
= partition_find (map
->var_partition
, x
);
367 gcc_assert (bitmap_bit_p (used
, p
));
368 bitmap_set_bit (new_partitions
, p
);
370 partition_view_fini (map
, new_partitions
);
374 var_map_base_init (map
);
376 var_map_base_fini (map
);
380 /* This function is used to change the representative variable in MAP for VAR's
381 partition to a regular non-ssa variable. This allows partitions to be
382 mapped back to real variables. */
385 change_partition_var (var_map map
, tree var
, int part
)
389 gcc_assert (TREE_CODE (var
) != SSA_NAME
);
392 ann
->out_of_ssa_tag
= 1;
393 VAR_ANN_PARTITION (ann
) = part
;
394 if (map
->view_to_partition
)
395 map
->partition_to_var
[map
->view_to_partition
[part
]] = var
;
399 static inline void mark_all_vars_used (tree
*);
401 /* Helper function for mark_all_vars_used, called via walk_tree. */
404 mark_all_vars_used_1 (tree
*tp
, int *walk_subtrees
,
405 void *data ATTRIBUTE_UNUSED
)
409 if (TREE_CODE (t
) == SSA_NAME
)
410 t
= SSA_NAME_VAR (t
);
412 /* Ignore TREE_ORIGINAL for TARGET_MEM_REFS, as well as other
413 fields that do not contain vars. */
414 if (TREE_CODE (t
) == TARGET_MEM_REF
)
416 mark_all_vars_used (&TMR_SYMBOL (t
));
417 mark_all_vars_used (&TMR_BASE (t
));
418 mark_all_vars_used (&TMR_INDEX (t
));
423 /* Only need to mark VAR_DECLS; parameters and return results are not
424 eliminated as unused. */
425 if (TREE_CODE (t
) == VAR_DECL
)
428 if (IS_TYPE_OR_DECL_P (t
))
435 /* Mark all VAR_DECLS under *EXPR_P as used, so that they won't be
436 eliminated during the tree->rtl conversion process. */
439 mark_all_vars_used (tree
*expr_p
)
441 walk_tree (expr_p
, mark_all_vars_used_1
, NULL
, NULL
);
445 /* Remove local variables that are not referenced in the IL. */
448 remove_unused_locals (void)
452 referenced_var_iterator rvi
;
455 /* Assume all locals are unused. */
456 FOR_EACH_REFERENCED_VAR (t
, rvi
)
457 var_ann (t
)->used
= false;
459 /* Walk the CFG marking all referenced symbols. */
462 block_stmt_iterator bsi
;
465 /* Walk the statements. */
466 for (bsi
= bsi_start (bb
); !bsi_end_p (bsi
); bsi_next (&bsi
))
467 mark_all_vars_used (bsi_stmt_ptr (bsi
));
469 for (phi
= phi_nodes (bb
); phi
; phi
= PHI_CHAIN (phi
))
474 /* No point processing globals. */
475 if (is_global_var (SSA_NAME_VAR (PHI_RESULT (phi
))))
478 def
= PHI_RESULT (phi
);
479 mark_all_vars_used (&def
);
481 FOR_EACH_PHI_ARG (arg_p
, phi
, i
, SSA_OP_ALL_USES
)
483 tree arg
= USE_FROM_PTR (arg_p
);
484 mark_all_vars_used (&arg
);
489 /* Remove unmarked vars and clear used flag. */
490 for (cell
= &cfun
->unexpanded_var_list
; *cell
; )
492 tree var
= TREE_VALUE (*cell
);
494 if (TREE_CODE (var
) != FUNCTION_DECL
495 && (!(ann
= var_ann (var
))
498 *cell
= TREE_CHAIN (*cell
);
502 cell
= &TREE_CHAIN (*cell
);
505 /* Remove unused variables from REFERENCED_VARs. As a special
506 exception keep the variables that are believed to be aliased.
507 Those can't be easily removed from the alias sets and operand
508 caches. They will be removed shortly after the next may_alias
509 pass is performed. */
510 FOR_EACH_REFERENCED_VAR (t
, rvi
)
511 if (!is_global_var (t
)
513 && TREE_CODE (t
) != PARM_DECL
514 && TREE_CODE (t
) != RESULT_DECL
515 && !(ann
= var_ann (t
))->used
516 && !ann
->symbol_mem_tag
517 && !TREE_ADDRESSABLE (t
))
518 remove_referenced_var (t
);
522 /* Allocate and return a new live range information object base on MAP. */
524 static tree_live_info_p
525 new_tree_live_info (var_map map
)
527 tree_live_info_p live
;
530 live
= (tree_live_info_p
) xmalloc (sizeof (struct tree_live_info_d
));
532 live
->num_blocks
= last_basic_block
;
534 live
->livein
= (bitmap
*)xmalloc (last_basic_block
* sizeof (bitmap
));
535 for (x
= 0; x
< (unsigned)last_basic_block
; x
++)
536 live
->livein
[x
] = BITMAP_ALLOC (NULL
);
538 live
->liveout
= (bitmap
*)xmalloc (last_basic_block
* sizeof (bitmap
));
539 for (x
= 0; x
< (unsigned)last_basic_block
; x
++)
540 live
->liveout
[x
] = BITMAP_ALLOC (NULL
);
542 live
->work_stack
= XNEWVEC (int, last_basic_block
);
543 live
->stack_top
= live
->work_stack
;
545 live
->global
= BITMAP_ALLOC (NULL
);
550 /* Free storage for live range info object LIVE. */
553 delete_tree_live_info (tree_live_info_p live
)
557 BITMAP_FREE (live
->global
);
558 free (live
->work_stack
);
560 for (x
= live
->num_blocks
- 1; x
>= 0; x
--)
561 BITMAP_FREE (live
->liveout
[x
]);
562 free (live
->liveout
);
564 for (x
= live
->num_blocks
- 1; x
>= 0; x
--)
565 BITMAP_FREE (live
->livein
[x
]);
572 /* Visit basic block BB and propagate any required live on entry bits from
573 LIVE into the predecessors. VISITED is the bitmap of visited blocks.
574 TMP is a temporary work bitmap which is passed in to avoid reallocating
578 loe_visit_block (tree_live_info_p live
, basic_block bb
, sbitmap visited
,
586 gcc_assert (!TEST_BIT (visited
, bb
->index
));
588 SET_BIT (visited
, bb
->index
);
589 loe
= live_on_entry (live
, bb
);
591 FOR_EACH_EDGE (e
, ei
, bb
->preds
)
594 if (pred_bb
== ENTRY_BLOCK_PTR
)
596 /* TMP is variables live-on-entry from BB that aren't defined in the
597 predecessor block. This should be the live on entry vars to pred.
598 Note that liveout is the DEFs in a block while live on entry is
600 bitmap_and_compl (tmp
, loe
, live
->liveout
[pred_bb
->index
]);
602 /* Add these bits to live-on-entry for the pred. if there are any
603 changes, and pred_bb has been visited already, add it to the
605 change
= bitmap_ior_into (live_on_entry (live
, pred_bb
), tmp
);
606 if (TEST_BIT (visited
, pred_bb
->index
) && change
)
608 RESET_BIT (visited
, pred_bb
->index
);
609 *(live
->stack_top
)++ = pred_bb
->index
;
615 /* Using LIVE, fill in all the live-on-entry blocks between the defs and uses
616 of all the variables. */
619 live_worklist (tree_live_info_p live
)
623 sbitmap visited
= sbitmap_alloc (last_basic_block
+ 1);
624 bitmap tmp
= BITMAP_ALLOC (NULL
);
626 sbitmap_zero (visited
);
628 /* Visit all the blocks in reverse order and propagate live on entry values
629 into the predecessors blocks. */
630 FOR_EACH_BB_REVERSE (bb
)
631 loe_visit_block (live
, bb
, visited
, tmp
);
633 /* Process any blocks which require further iteration. */
634 while (live
->stack_top
!= live
->work_stack
)
636 b
= *--(live
->stack_top
);
637 loe_visit_block (live
, BASIC_BLOCK (b
), visited
, tmp
);
641 sbitmap_free (visited
);
645 /* Calculate the initial live on entry vector for SSA_NAME using immediate_use
646 links. Set the live on entry fields in LIVE. Def's are marked temporarily
647 in the liveout vector. */
650 set_var_live_on_entry (tree ssa_name
, tree_live_info_p live
)
655 basic_block def_bb
= NULL
;
656 imm_use_iterator imm_iter
;
659 p
= var_to_partition (live
->map
, ssa_name
);
660 if (p
== NO_PARTITION
)
663 stmt
= SSA_NAME_DEF_STMT (ssa_name
);
666 def_bb
= bb_for_stmt (stmt
);
667 /* Mark defs in liveout bitmap temporarily. */
669 bitmap_set_bit (live
->liveout
[def_bb
->index
], p
);
672 def_bb
= ENTRY_BLOCK_PTR
;
674 /* Visit each use of SSA_NAME and if it isn't in the same block as the def,
675 add it to the list of live on entry blocks. */
676 FOR_EACH_IMM_USE_FAST (use
, imm_iter
, ssa_name
)
678 tree use_stmt
= USE_STMT (use
);
679 basic_block add_block
= NULL
;
681 if (TREE_CODE (use_stmt
) == PHI_NODE
)
683 /* Uses in PHI's are considered to be live at exit of the SRC block
684 as this is where a copy would be inserted. Check to see if it is
685 defined in that block, or whether its live on entry. */
686 int index
= PHI_ARG_INDEX_FROM_USE (use
);
687 edge e
= PHI_ARG_EDGE (use_stmt
, index
);
688 if (e
->src
!= ENTRY_BLOCK_PTR
)
690 if (e
->src
!= def_bb
)
696 /* If its not defined in this block, its live on entry. */
697 basic_block use_bb
= bb_for_stmt (use_stmt
);
698 if (use_bb
!= def_bb
)
702 /* If there was a live on entry use, set the bit. */
706 bitmap_set_bit (live
->livein
[add_block
->index
], p
);
710 /* If SSA_NAME is live on entry to at least one block, fill in all the live
711 on entry blocks between the def and all the uses. */
713 bitmap_set_bit (live
->global
, p
);
717 /* Calculate the live on exit vectors based on the entry info in LIVEINFO. */
720 calculate_live_on_exit (tree_live_info_p liveinfo
)
729 /* live on entry calculations used liveout vectors for defs, clear them. */
731 bitmap_clear (liveinfo
->liveout
[bb
->index
]);
733 /* Set all the live-on-exit bits for uses in PHIs. */
736 /* Mark the PHI arguments which are live on exit to the pred block. */
737 for (phi
= phi_nodes (bb
); phi
; phi
= PHI_CHAIN (phi
))
738 for (i
= 0; i
< (unsigned)PHI_NUM_ARGS (phi
); i
++)
740 t
= PHI_ARG_DEF (phi
, i
);
741 if (TREE_CODE (t
) != SSA_NAME
)
743 p
= var_to_partition (liveinfo
->map
, t
);
744 if (p
== NO_PARTITION
)
746 e
= PHI_ARG_EDGE (phi
, i
);
747 if (e
->src
!= ENTRY_BLOCK_PTR
)
748 bitmap_set_bit (liveinfo
->liveout
[e
->src
->index
], p
);
751 /* Add each successors live on entry to this bock live on exit. */
752 FOR_EACH_EDGE (e
, ei
, bb
->succs
)
753 if (e
->dest
!= EXIT_BLOCK_PTR
)
754 bitmap_ior_into (liveinfo
->liveout
[bb
->index
],
755 live_on_entry (liveinfo
, e
->dest
));
760 /* Given partition map MAP, calculate all the live on entry bitmaps for
761 each partition. Return a new live info object. */
764 calculate_live_ranges (var_map map
)
768 tree_live_info_p live
;
770 live
= new_tree_live_info (map
);
771 for (i
= 0; i
< num_var_partitions (map
); i
++)
773 var
= partition_to_var (map
, i
);
774 if (var
!= NULL_TREE
)
775 set_var_live_on_entry (var
, live
);
778 live_worklist (live
);
780 #ifdef ENABLE_CHECKING
781 verify_live_on_entry (live
);
784 calculate_live_on_exit (live
);
789 /* Output partition map MAP to file F. */
792 dump_var_map (FILE *f
, var_map map
)
798 fprintf (f
, "\nPartition map \n\n");
800 for (x
= 0; x
< map
->num_partitions
; x
++)
802 if (map
->view_to_partition
!= NULL
)
803 p
= map
->view_to_partition
[x
];
807 if (map
->partition_to_var
[p
] == NULL_TREE
)
811 for (y
= 1; y
< num_ssa_names
; y
++)
813 p
= partition_find (map
->var_partition
, y
);
814 if (map
->partition_to_view
)
815 p
= map
->partition_to_view
[p
];
820 fprintf(f
, "Partition %d (", x
);
821 print_generic_expr (f
, partition_to_var (map
, p
), TDF_SLIM
);
824 fprintf (f
, "%d ", y
);
834 /* Output live range info LIVE to file F, controlled by FLAG. */
837 dump_live_info (FILE *f
, tree_live_info_p live
, int flag
)
841 var_map map
= live
->map
;
844 if ((flag
& LIVEDUMP_ENTRY
) && live
->livein
)
848 fprintf (f
, "\nLive on entry to BB%d : ", bb
->index
);
849 EXECUTE_IF_SET_IN_BITMAP (live
->livein
[bb
->index
], 0, i
, bi
)
851 print_generic_expr (f
, partition_to_var (map
, i
), TDF_SLIM
);
858 if ((flag
& LIVEDUMP_EXIT
) && live
->liveout
)
862 fprintf (f
, "\nLive on exit from BB%d : ", bb
->index
);
863 EXECUTE_IF_SET_IN_BITMAP (live
->liveout
[bb
->index
], 0, i
, bi
)
865 print_generic_expr (f
, partition_to_var (map
, i
), TDF_SLIM
);
874 #ifdef ENABLE_CHECKING
875 /* Verify that SSA_VAR is a non-virtual SSA_NAME. */
878 register_ssa_partition_check (tree ssa_var
)
880 gcc_assert (TREE_CODE (ssa_var
) == SSA_NAME
);
881 if (!is_gimple_reg (SSA_NAME_VAR (ssa_var
)))
883 fprintf (stderr
, "Illegally registering a virtual SSA name :");
884 print_generic_expr (stderr
, ssa_var
, TDF_SLIM
);
885 fprintf (stderr
, " in the SSA->Normal phase.\n");
886 internal_error ("SSA corruption");
891 /* Verify that the info in LIVE matches the current cfg. */
894 verify_live_on_entry (tree_live_info_p live
)
903 var_map map
= live
->map
;
905 /* Check for live on entry partitions and report those with a DEF in
906 the program. This will typically mean an optimization has done
908 bb
= ENTRY_BLOCK_PTR
;
910 FOR_EACH_EDGE (e
, ei
, bb
->succs
)
912 int entry_block
= e
->dest
->index
;
913 if (e
->dest
== EXIT_BLOCK_PTR
)
915 for (i
= 0; i
< (unsigned)num_var_partitions (map
); i
++)
920 var
= partition_to_var (map
, i
);
921 stmt
= SSA_NAME_DEF_STMT (var
);
922 tmp
= bb_for_stmt (stmt
);
923 d
= gimple_default_def (cfun
, SSA_NAME_VAR (var
));
925 loe
= live_on_entry (live
, e
->dest
);
926 if (loe
&& bitmap_bit_p (loe
, i
))
928 if (!IS_EMPTY_STMT (stmt
))
931 print_generic_expr (stderr
, var
, TDF_SLIM
);
932 fprintf (stderr
, " is defined ");
934 fprintf (stderr
, " in BB%d, ", tmp
->index
);
935 fprintf (stderr
, "by:\n");
936 print_generic_expr (stderr
, stmt
, TDF_SLIM
);
937 fprintf (stderr
, "\nIt is also live-on-entry to entry BB %d",
939 fprintf (stderr
, " So it appears to have multiple defs.\n");
946 print_generic_expr (stderr
, var
, TDF_SLIM
);
947 fprintf (stderr
, " is live-on-entry to BB%d ",entry_block
);
950 fprintf (stderr
, " but is not the default def of ");
951 print_generic_expr (stderr
, d
, TDF_SLIM
);
952 fprintf (stderr
, "\n");
955 fprintf (stderr
, " and there is no default def.\n");
962 /* The only way this var shouldn't be marked live on entry is
963 if it occurs in a PHI argument of the block. */
965 for (phi
= phi_nodes (e
->dest
);
967 phi
= PHI_CHAIN (phi
))
969 for (z
= 0; z
< PHI_NUM_ARGS (phi
); z
++)
970 if (var
== PHI_ARG_DEF (phi
, z
))
979 print_generic_expr (stderr
, var
, TDF_SLIM
);
980 fprintf (stderr
, " is not marked live-on-entry to entry BB%d ",
982 fprintf (stderr
, "but it is a default def so it should be.\n");
986 gcc_assert (num
<= 0);