Mercurial > hg > CbC > CbC_gcc
comparison gcc/tree-ssa-dce.c @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | 84e7813d76e9 |
children |
comparison
equal
deleted
inserted
replaced
131:84e7813d76e9 | 145:1830386684a0 |
---|---|
1 /* Dead code elimination pass for the GNU compiler. | 1 /* Dead code elimination pass for the GNU compiler. |
2 Copyright (C) 2002-2018 Free Software Foundation, Inc. | 2 Copyright (C) 2002-2020 Free Software Foundation, Inc. |
3 Contributed by Ben Elliston <bje@redhat.com> | 3 Contributed by Ben Elliston <bje@redhat.com> |
4 and Andrew MacLeod <amacleod@redhat.com> | 4 and Andrew MacLeod <amacleod@redhat.com> |
5 Adapted to use control dependence by Steven Bosscher, SUSE Labs. | 5 Adapted to use control dependence by Steven Bosscher, SUSE Labs. |
6 | 6 |
7 This file is part of GCC. | 7 This file is part of GCC. |
113 | 113 |
114 /* When non-NULL holds map from basic block index into the postorder. */ | 114 /* When non-NULL holds map from basic block index into the postorder. */ |
115 static int *bb_postorder; | 115 static int *bb_postorder; |
116 | 116 |
117 | 117 |
118 /* True if we should treat any stmt with a vdef as necessary. */ | |
119 | |
120 static inline bool | |
121 keep_all_vdefs_p () | |
122 { | |
123 return optimize_debug; | |
124 } | |
125 | |
118 /* If STMT is not already marked necessary, mark it, and add it to the | 126 /* If STMT is not already marked necessary, mark it, and add it to the |
119 worklist if ADD_TO_WORKLIST is true. */ | 127 worklist if ADD_TO_WORKLIST is true. */ |
120 | 128 |
121 static inline void | 129 static inline void |
122 mark_stmt_necessary (gimple *stmt, bool add_to_worklist) | 130 mark_stmt_necessary (gimple *stmt, bool add_to_worklist) |
235 case BUILT_IN_STRNDUP: | 243 case BUILT_IN_STRNDUP: |
236 return; | 244 return; |
237 | 245 |
238 default:; | 246 default:; |
239 } | 247 } |
248 | |
249 if (callee != NULL_TREE | |
250 && flag_allocation_dce | |
251 && DECL_IS_REPLACEABLE_OPERATOR_NEW_P (callee)) | |
252 return; | |
253 | |
240 /* Most, but not all function calls are required. Function calls that | 254 /* Most, but not all function calls are required. Function calls that |
241 produce no result and have no side effects (i.e. const pure | 255 produce no result and have no side effects (i.e. const pure |
242 functions) are unnecessary. */ | 256 functions) are unnecessary. */ |
243 if (gimple_has_side_effects (stmt)) | 257 if (gimple_has_side_effects (stmt)) |
258 { | |
259 mark_stmt_necessary (stmt, true); | |
260 return; | |
261 } | |
262 /* IFN_GOACC_LOOP calls are necessary in that they are used to | |
263 represent parameter (i.e. step, bound) of a lowered OpenACC | |
264 partitioned loop. But this kind of partitioned loop might not | |
265 survive from aggressive loop removal for it has loop exit and | |
266 is assumed to be finite. Therefore, we need to explicitly mark | |
267 these calls. (An example is libgomp.oacc-c-c++-common/pr84955.c) */ | |
268 if (gimple_call_internal_p (stmt, IFN_GOACC_LOOP)) | |
244 { | 269 { |
245 mark_stmt_necessary (stmt, true); | 270 mark_stmt_necessary (stmt, true); |
246 return; | 271 return; |
247 } | 272 } |
248 if (!gimple_call_lhs (stmt)) | 273 if (!gimple_call_lhs (stmt)) |
298 { | 323 { |
299 mark_stmt_necessary (stmt, true); | 324 mark_stmt_necessary (stmt, true); |
300 return; | 325 return; |
301 } | 326 } |
302 | 327 |
328 if (gimple_vdef (stmt) && keep_all_vdefs_p ()) | |
329 { | |
330 mark_stmt_necessary (stmt, true); | |
331 return; | |
332 } | |
333 | |
303 return; | 334 return; |
304 } | 335 } |
305 | 336 |
306 | 337 |
307 /* Mark the last statement of BB as necessary. */ | 338 /* Mark the last statement of BB as necessary. */ |
398 return; | 429 return; |
399 | 430 |
400 /* Prevent the empty possibly infinite loops from being removed. */ | 431 /* Prevent the empty possibly infinite loops from being removed. */ |
401 if (aggressive) | 432 if (aggressive) |
402 { | 433 { |
403 struct loop *loop; | 434 class loop *loop; |
404 if (mark_irreducible_loops ()) | 435 if (mark_irreducible_loops ()) |
405 FOR_EACH_BB_FN (bb, cfun) | 436 FOR_EACH_BB_FN (bb, cfun) |
406 { | 437 { |
407 edge_iterator ei; | 438 edge_iterator ei; |
408 FOR_EACH_EDGE (e, ei, bb->succs) | 439 FOR_EACH_EDGE (e, ei, bb->succs) |
418 | 449 |
419 FOR_EACH_LOOP (loop, 0) | 450 FOR_EACH_LOOP (loop, 0) |
420 if (!finite_loop_p (loop)) | 451 if (!finite_loop_p (loop)) |
421 { | 452 { |
422 if (dump_file) | 453 if (dump_file) |
423 fprintf (dump_file, "can not prove finiteness of loop %i\n", loop->num); | 454 fprintf (dump_file, "cannot prove finiteness of loop %i\n", loop->num); |
424 mark_control_dependent_edges_necessary (loop->latch, false); | 455 mark_control_dependent_edges_necessary (loop->latch, false); |
425 } | 456 } |
426 } | 457 } |
427 } | 458 } |
428 | 459 |
513 } | 544 } |
514 | 545 |
515 static void | 546 static void |
516 mark_aliased_reaching_defs_necessary (gimple *stmt, tree ref) | 547 mark_aliased_reaching_defs_necessary (gimple *stmt, tree ref) |
517 { | 548 { |
549 /* Should have been caught before calling this function. */ | |
550 gcc_checking_assert (!keep_all_vdefs_p ()); | |
551 | |
518 unsigned int chain; | 552 unsigned int chain; |
519 ao_ref refd; | 553 ao_ref refd; |
520 gcc_assert (!chain_ovfl); | 554 gcc_assert (!chain_ovfl); |
521 ao_ref_init (&refd, ref); | 555 ao_ref_init (&refd, ref); |
522 chain = walk_aliased_vdefs (&refd, gimple_vuse (stmt), | 556 chain = walk_aliased_vdefs (&refd, gimple_vuse (stmt), |
575 case BUILT_IN_FREE: | 609 case BUILT_IN_FREE: |
576 return false; | 610 return false; |
577 | 611 |
578 default:; | 612 default:; |
579 } | 613 } |
614 | |
615 if (callee != NULL_TREE | |
616 && (DECL_IS_REPLACEABLE_OPERATOR_NEW_P (callee) | |
617 || DECL_IS_OPERATOR_DELETE_P (callee))) | |
618 return false; | |
580 } | 619 } |
581 | 620 |
582 if (! gimple_clobber_p (def_stmt)) | 621 if (! gimple_clobber_p (def_stmt)) |
583 mark_operand_necessary (vdef); | 622 mark_operand_necessary (vdef); |
584 | 623 |
586 } | 625 } |
587 | 626 |
588 static void | 627 static void |
589 mark_all_reaching_defs_necessary (gimple *stmt) | 628 mark_all_reaching_defs_necessary (gimple *stmt) |
590 { | 629 { |
630 /* Should have been caught before calling this function. */ | |
631 gcc_checking_assert (!keep_all_vdefs_p ()); | |
591 walk_aliased_vdefs (NULL, gimple_vuse (stmt), | 632 walk_aliased_vdefs (NULL, gimple_vuse (stmt), |
592 mark_all_reaching_defs_necessary_1, NULL, &visited); | 633 mark_all_reaching_defs_necessary_1, NULL, &visited); |
593 } | 634 } |
594 | 635 |
595 /* Return true for PHI nodes with one or identical arguments | 636 /* Return true for PHI nodes with one or identical arguments |
761 tree use; | 802 tree use; |
762 | 803 |
763 /* If this is a call to free which is directly fed by an | 804 /* If this is a call to free which is directly fed by an |
764 allocation function do not mark that necessary through | 805 allocation function do not mark that necessary through |
765 processing the argument. */ | 806 processing the argument. */ |
766 if (gimple_call_builtin_p (stmt, BUILT_IN_FREE)) | 807 bool is_delete_operator |
808 = (is_gimple_call (stmt) | |
809 && gimple_call_operator_delete_p (as_a <gcall *> (stmt))); | |
810 if (is_delete_operator | |
811 || gimple_call_builtin_p (stmt, BUILT_IN_FREE)) | |
767 { | 812 { |
768 tree ptr = gimple_call_arg (stmt, 0); | 813 tree ptr = gimple_call_arg (stmt, 0); |
769 gimple *def_stmt; | 814 gimple *def_stmt; |
770 tree def_callee; | 815 tree def_callee; |
771 /* If the pointer we free is defined by an allocation | 816 /* If the pointer we free is defined by an allocation |
772 function do not add the call to the worklist. */ | 817 function do not add the call to the worklist. */ |
773 if (TREE_CODE (ptr) == SSA_NAME | 818 if (TREE_CODE (ptr) == SSA_NAME |
774 && is_gimple_call (def_stmt = SSA_NAME_DEF_STMT (ptr)) | 819 && is_gimple_call (def_stmt = SSA_NAME_DEF_STMT (ptr)) |
775 && (def_callee = gimple_call_fndecl (def_stmt)) | 820 && (def_callee = gimple_call_fndecl (def_stmt)) |
776 && DECL_BUILT_IN_CLASS (def_callee) == BUILT_IN_NORMAL | 821 && ((DECL_BUILT_IN_CLASS (def_callee) == BUILT_IN_NORMAL |
777 && (DECL_FUNCTION_CODE (def_callee) == BUILT_IN_ALIGNED_ALLOC | 822 && (DECL_FUNCTION_CODE (def_callee) == BUILT_IN_ALIGNED_ALLOC |
778 || DECL_FUNCTION_CODE (def_callee) == BUILT_IN_MALLOC | 823 || DECL_FUNCTION_CODE (def_callee) == BUILT_IN_MALLOC |
779 || DECL_FUNCTION_CODE (def_callee) == BUILT_IN_CALLOC)) | 824 || DECL_FUNCTION_CODE (def_callee) == BUILT_IN_CALLOC)) |
780 continue; | 825 || DECL_IS_REPLACEABLE_OPERATOR_NEW_P (def_callee))) |
826 { | |
827 /* Delete operators can have alignment and (or) size as next | |
828 arguments. When being a SSA_NAME, they must be marked | |
829 as necessary. */ | |
830 if (is_delete_operator && gimple_call_num_args (stmt) >= 2) | |
831 for (unsigned i = 1; i < gimple_call_num_args (stmt); i++) | |
832 { | |
833 tree arg = gimple_call_arg (stmt, i); | |
834 if (TREE_CODE (arg) == SSA_NAME) | |
835 mark_operand_necessary (arg); | |
836 } | |
837 | |
838 continue; | |
839 } | |
781 } | 840 } |
782 | 841 |
783 FOR_EACH_SSA_TREE_OPERAND (use, stmt, iter, SSA_OP_USE) | 842 FOR_EACH_SSA_TREE_OPERAND (use, stmt, iter, SSA_OP_USE) |
784 mark_operand_necessary (use); | 843 mark_operand_necessary (use); |
785 | 844 |
786 use = gimple_vuse (stmt); | 845 use = gimple_vuse (stmt); |
787 if (!use) | 846 if (!use) |
847 continue; | |
848 | |
849 /* No need to search for vdefs if we intrinsicly keep them all. */ | |
850 if (keep_all_vdefs_p ()) | |
788 continue; | 851 continue; |
789 | 852 |
790 /* If we dropped to simple mode make all immediately | 853 /* If we dropped to simple mode make all immediately |
791 reachable definitions necessary. */ | 854 reachable definitions necessary. */ |
792 if (chain_ovfl) | 855 if (chain_ovfl) |
829 || DECL_FUNCTION_CODE (callee) == BUILT_IN_STACK_SAVE | 892 || DECL_FUNCTION_CODE (callee) == BUILT_IN_STACK_SAVE |
830 || DECL_FUNCTION_CODE (callee) == BUILT_IN_STACK_RESTORE | 893 || DECL_FUNCTION_CODE (callee) == BUILT_IN_STACK_RESTORE |
831 || DECL_FUNCTION_CODE (callee) == BUILT_IN_ASSUME_ALIGNED)) | 894 || DECL_FUNCTION_CODE (callee) == BUILT_IN_ASSUME_ALIGNED)) |
832 continue; | 895 continue; |
833 | 896 |
897 if (callee != NULL_TREE | |
898 && (DECL_IS_REPLACEABLE_OPERATOR_NEW_P (callee) | |
899 || DECL_IS_OPERATOR_DELETE_P (callee))) | |
900 continue; | |
901 | |
834 /* Calls implicitly load from memory, their arguments | 902 /* Calls implicitly load from memory, their arguments |
835 in addition may explicitly perform memory loads. */ | 903 in addition may explicitly perform memory loads. */ |
836 mark_all_reaching_defs_necessary (stmt); | 904 mark_all_reaching_defs_necessary (stmt); |
837 for (i = 0; i < gimple_call_num_args (stmt); ++i) | 905 for (i = 0; i < gimple_call_num_args (stmt); ++i) |
838 { | 906 { |
983 | 1051 |
984 /* Remove dead statement pointed to by iterator I. Receives the basic block BB | 1052 /* Remove dead statement pointed to by iterator I. Receives the basic block BB |
985 containing I so that we don't have to look it up. */ | 1053 containing I so that we don't have to look it up. */ |
986 | 1054 |
987 static void | 1055 static void |
988 remove_dead_stmt (gimple_stmt_iterator *i, basic_block bb) | 1056 remove_dead_stmt (gimple_stmt_iterator *i, basic_block bb, |
1057 vec<edge> &to_remove_edges) | |
989 { | 1058 { |
990 gimple *stmt = gsi_stmt (*i); | 1059 gimple *stmt = gsi_stmt (*i); |
991 | 1060 |
992 if (dump_file && (dump_flags & TDF_DETAILS)) | 1061 if (dump_file && (dump_flags & TDF_DETAILS)) |
993 { | 1062 { |
1043 | 1112 |
1044 /* The lone outgoing edge from BB will be a fallthru edge. */ | 1113 /* The lone outgoing edge from BB will be a fallthru edge. */ |
1045 e->flags |= EDGE_FALLTHRU; | 1114 e->flags |= EDGE_FALLTHRU; |
1046 | 1115 |
1047 /* Remove the remaining outgoing edges. */ | 1116 /* Remove the remaining outgoing edges. */ |
1048 for (ei = ei_start (bb->succs); (e2 = ei_safe_edge (ei)); ) | 1117 FOR_EACH_EDGE (e2, ei, bb->succs) |
1049 if (e != e2) | 1118 if (e != e2) |
1050 { | 1119 { |
1051 cfg_altered = true; | |
1052 /* If we made a BB unconditionally exit a loop or removed | 1120 /* If we made a BB unconditionally exit a loop or removed |
1053 an entry into an irreducible region, then this transform | 1121 an entry into an irreducible region, then this transform |
1054 alters the set of BBs in the loop. Schedule a fixup. */ | 1122 alters the set of BBs in the loop. Schedule a fixup. */ |
1055 if (loop_exit_edge_p (bb->loop_father, e) | 1123 if (loop_exit_edge_p (bb->loop_father, e) |
1056 || (e2->dest->flags & BB_IRREDUCIBLE_LOOP)) | 1124 || (e2->dest->flags & BB_IRREDUCIBLE_LOOP)) |
1057 loops_state_set (LOOPS_NEED_FIXUP); | 1125 loops_state_set (LOOPS_NEED_FIXUP); |
1058 remove_edge (e2); | 1126 to_remove_edges.safe_push (e2); |
1059 } | 1127 } |
1060 else | |
1061 ei_next (&ei); | |
1062 } | 1128 } |
1063 | 1129 |
1064 /* If this is a store into a variable that is being optimized away, | 1130 /* If this is a store into a variable that is being optimized away, |
1065 add a debug bind stmt if possible. */ | 1131 add a debug bind stmt if possible. */ |
1066 if (MAY_HAVE_DEBUG_BIND_STMTS | 1132 if (MAY_HAVE_DEBUG_BIND_STMTS |
1199 basic_block bb; | 1265 basic_block bb; |
1200 gimple_stmt_iterator gsi, psi; | 1266 gimple_stmt_iterator gsi, psi; |
1201 gimple *stmt; | 1267 gimple *stmt; |
1202 tree call; | 1268 tree call; |
1203 vec<basic_block> h; | 1269 vec<basic_block> h; |
1270 auto_vec<edge> to_remove_edges; | |
1204 | 1271 |
1205 if (dump_file && (dump_flags & TDF_DETAILS)) | 1272 if (dump_file && (dump_flags & TDF_DETAILS)) |
1206 fprintf (dump_file, "\nEliminating unnecessary statements:\n"); | 1273 fprintf (dump_file, "\nEliminating unnecessary statements:\n"); |
1207 | 1274 |
1208 clear_special_calls (); | 1275 clear_special_calls (); |
1236 while (h.length ()) | 1303 while (h.length ()) |
1237 { | 1304 { |
1238 bb = h.pop (); | 1305 bb = h.pop (); |
1239 | 1306 |
1240 /* Remove dead statements. */ | 1307 /* Remove dead statements. */ |
1308 auto_bitmap debug_seen; | |
1241 for (gsi = gsi_last_bb (bb); !gsi_end_p (gsi); gsi = psi) | 1309 for (gsi = gsi_last_bb (bb); !gsi_end_p (gsi); gsi = psi) |
1242 { | 1310 { |
1243 stmt = gsi_stmt (gsi); | 1311 stmt = gsi_stmt (gsi); |
1244 | 1312 |
1245 psi = gsi; | 1313 psi = gsi; |
1249 | 1317 |
1250 /* We can mark a call to free as not necessary if the | 1318 /* We can mark a call to free as not necessary if the |
1251 defining statement of its argument is not necessary | 1319 defining statement of its argument is not necessary |
1252 (and thus is getting removed). */ | 1320 (and thus is getting removed). */ |
1253 if (gimple_plf (stmt, STMT_NECESSARY) | 1321 if (gimple_plf (stmt, STMT_NECESSARY) |
1254 && gimple_call_builtin_p (stmt, BUILT_IN_FREE)) | 1322 && (gimple_call_builtin_p (stmt, BUILT_IN_FREE) |
1323 || (is_gimple_call (stmt) | |
1324 && gimple_call_operator_delete_p (as_a <gcall *> (stmt))))) | |
1255 { | 1325 { |
1256 tree ptr = gimple_call_arg (stmt, 0); | 1326 tree ptr = gimple_call_arg (stmt, 0); |
1257 if (TREE_CODE (ptr) == SSA_NAME) | 1327 if (TREE_CODE (ptr) == SSA_NAME) |
1258 { | 1328 { |
1259 gimple *def_stmt = SSA_NAME_DEF_STMT (ptr); | 1329 gimple *def_stmt = SSA_NAME_DEF_STMT (ptr); |
1281 dead = true; | 1351 dead = true; |
1282 break; | 1352 break; |
1283 } | 1353 } |
1284 } | 1354 } |
1285 if (!dead) | 1355 if (!dead) |
1286 continue; | 1356 { |
1357 bitmap_clear (debug_seen); | |
1358 continue; | |
1359 } | |
1287 } | 1360 } |
1288 if (!is_gimple_debug (stmt)) | 1361 if (!is_gimple_debug (stmt)) |
1289 something_changed = true; | 1362 something_changed = true; |
1290 remove_dead_stmt (&gsi, bb); | 1363 remove_dead_stmt (&gsi, bb, to_remove_edges); |
1364 continue; | |
1291 } | 1365 } |
1292 else if (is_gimple_call (stmt)) | 1366 else if (is_gimple_call (stmt)) |
1293 { | 1367 { |
1294 tree name = gimple_call_lhs (stmt); | 1368 tree name = gimple_call_lhs (stmt); |
1295 | 1369 |
1302 && !bitmap_bit_p (processed, SSA_NAME_VERSION (name)) | 1376 && !bitmap_bit_p (processed, SSA_NAME_VERSION (name)) |
1303 /* Avoid doing so for allocation calls which we | 1377 /* Avoid doing so for allocation calls which we |
1304 did not mark as necessary, it will confuse the | 1378 did not mark as necessary, it will confuse the |
1305 special logic we apply to malloc/free pair removal. */ | 1379 special logic we apply to malloc/free pair removal. */ |
1306 && (!(call = gimple_call_fndecl (stmt)) | 1380 && (!(call = gimple_call_fndecl (stmt)) |
1307 || DECL_BUILT_IN_CLASS (call) != BUILT_IN_NORMAL | 1381 || ((DECL_BUILT_IN_CLASS (call) != BUILT_IN_NORMAL |
1308 || (DECL_FUNCTION_CODE (call) != BUILT_IN_ALIGNED_ALLOC | 1382 || (DECL_FUNCTION_CODE (call) != BUILT_IN_ALIGNED_ALLOC |
1309 && DECL_FUNCTION_CODE (call) != BUILT_IN_MALLOC | 1383 && DECL_FUNCTION_CODE (call) != BUILT_IN_MALLOC |
1310 && DECL_FUNCTION_CODE (call) != BUILT_IN_CALLOC | 1384 && DECL_FUNCTION_CODE (call) != BUILT_IN_CALLOC |
1311 && !ALLOCA_FUNCTION_CODE_P | 1385 && !ALLOCA_FUNCTION_CODE_P |
1312 (DECL_FUNCTION_CODE (call))))) | 1386 (DECL_FUNCTION_CODE (call)))) |
1387 && !DECL_IS_REPLACEABLE_OPERATOR_NEW_P (call)))) | |
1313 { | 1388 { |
1314 something_changed = true; | 1389 something_changed = true; |
1315 if (dump_file && (dump_flags & TDF_DETAILS)) | 1390 if (dump_file && (dump_flags & TDF_DETAILS)) |
1316 { | 1391 { |
1317 fprintf (dump_file, "Deleting LHS of call: "); | 1392 fprintf (dump_file, "Deleting LHS of call: "); |
1322 gimple_call_set_lhs (stmt, NULL_TREE); | 1397 gimple_call_set_lhs (stmt, NULL_TREE); |
1323 maybe_clean_or_replace_eh_stmt (stmt, stmt); | 1398 maybe_clean_or_replace_eh_stmt (stmt, stmt); |
1324 update_stmt (stmt); | 1399 update_stmt (stmt); |
1325 release_ssa_name (name); | 1400 release_ssa_name (name); |
1326 | 1401 |
1327 /* GOMP_SIMD_LANE or ASAN_POISON without lhs is not | 1402 /* GOMP_SIMD_LANE (unless three argument) or ASAN_POISON |
1328 needed. */ | 1403 without lhs is not needed. */ |
1329 if (gimple_call_internal_p (stmt)) | 1404 if (gimple_call_internal_p (stmt)) |
1330 switch (gimple_call_internal_fn (stmt)) | 1405 switch (gimple_call_internal_fn (stmt)) |
1331 { | 1406 { |
1332 case IFN_GOMP_SIMD_LANE: | 1407 case IFN_GOMP_SIMD_LANE: |
1408 if (gimple_call_num_args (stmt) >= 3 | |
1409 && !integer_nonzerop (gimple_call_arg (stmt, 2))) | |
1410 break; | |
1411 /* FALLTHRU */ | |
1333 case IFN_ASAN_POISON: | 1412 case IFN_ASAN_POISON: |
1334 remove_dead_stmt (&gsi, bb); | 1413 remove_dead_stmt (&gsi, bb, to_remove_edges); |
1335 break; | 1414 break; |
1336 default: | 1415 default: |
1337 break; | 1416 break; |
1338 } | 1417 } |
1339 } | 1418 } |
1351 break; | 1430 break; |
1352 default: | 1431 default: |
1353 break; | 1432 break; |
1354 } | 1433 } |
1355 } | 1434 } |
1435 else if (gimple_debug_bind_p (stmt)) | |
1436 { | |
1437 /* We are only keeping the last debug-bind of a | |
1438 non-DEBUG_EXPR_DECL variable in a series of | |
1439 debug-bind stmts. */ | |
1440 tree var = gimple_debug_bind_get_var (stmt); | |
1441 if (TREE_CODE (var) != DEBUG_EXPR_DECL | |
1442 && !bitmap_set_bit (debug_seen, DECL_UID (var))) | |
1443 remove_dead_stmt (&gsi, bb, to_remove_edges); | |
1444 continue; | |
1445 } | |
1446 bitmap_clear (debug_seen); | |
1356 } | 1447 } |
1448 | |
1449 /* Remove dead PHI nodes. */ | |
1450 something_changed |= remove_dead_phis (bb); | |
1357 } | 1451 } |
1358 | 1452 |
1359 h.release (); | 1453 h.release (); |
1360 | 1454 |
1361 /* Since we don't track liveness of virtual PHI nodes, it is possible that we | 1455 /* Since we don't track liveness of virtual PHI nodes, it is possible that we |
1362 rendered some PHI nodes unreachable while they are still in use. | 1456 rendered some PHI nodes unreachable while they are still in use. |
1363 Mark them for renaming. */ | 1457 Mark them for renaming. */ |
1364 if (cfg_altered) | 1458 if (!to_remove_edges.is_empty ()) |
1365 { | 1459 { |
1366 basic_block prev_bb; | 1460 basic_block prev_bb; |
1461 | |
1462 /* Remove edges. We've delayed this to not get bogus debug stmts | |
1463 during PHI node removal. */ | |
1464 for (unsigned i = 0; i < to_remove_edges.length (); ++i) | |
1465 remove_edge (to_remove_edges[i]); | |
1466 cfg_altered = true; | |
1367 | 1467 |
1368 find_unreachable_blocks (); | 1468 find_unreachable_blocks (); |
1369 | 1469 |
1370 /* Delete all unreachable basic blocks in reverse dominator order. */ | 1470 /* Delete all unreachable basic blocks in reverse dominator order. */ |
1371 for (bb = EXIT_BLOCK_PTR_FOR_FN (cfun)->prev_bb; | 1471 for (bb = EXIT_BLOCK_PTR_FOR_FN (cfun)->prev_bb; |
1428 } | 1528 } |
1429 } | 1529 } |
1430 } | 1530 } |
1431 } | 1531 } |
1432 } | 1532 } |
1433 FOR_EACH_BB_FN (bb, cfun) | |
1434 { | |
1435 /* Remove dead PHI nodes. */ | |
1436 something_changed |= remove_dead_phis (bb); | |
1437 } | |
1438 | 1533 |
1439 if (bb_postorder) | 1534 if (bb_postorder) |
1440 free (bb_postorder); | 1535 free (bb_postorder); |
1441 bb_postorder = NULL; | 1536 bb_postorder = NULL; |
1442 | 1537 |