From 58ad6b2802592f1448eed48e8ad4e0e87985cecb Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Thu, 25 Feb 2021 11:31:37 +0100 Subject: First do add_noreturn_fake_exit_edges in connect_infinite_loops_to_exit Most callers of connect_infinite_loops_to_exit already do this but the few that do not end up with extra exit edges. The following makes that consistent, also matching the post-dominance DFS walk code. 2021-02-25 Richard Biener * cfganal.c (connect_infinite_loops_to_exit): First call add_noreturn_fake_exit_edges. * ipa-sra.c (process_scan_results): Do not call the now redundant add_noreturn_fake_exit_edges. * predict.c (tree_estimate_probability): Likewise. (rebuild_frequencies): Likewise. * store-motion.c (one_store_motion_pass): Likewise. --- gcc/cfganal.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'gcc/cfganal.c') diff --git a/gcc/cfganal.c b/gcc/cfganal.c index 2627c2f..cec5abe 100644 --- a/gcc/cfganal.c +++ b/gcc/cfganal.c @@ -582,9 +582,9 @@ add_noreturn_fake_exit_edges (void) make_single_succ_edge (bb, EXIT_BLOCK_PTR_FOR_FN (cfun), EDGE_FAKE); } -/* This function adds a fake edge between any infinite loops to the - exit block. Some optimizations require a path from each node to - the exit node. +/* This function adds a fake edge between any noreturn block and + infinite loops to the exit block. Some optimizations require a path + from each node to the exit node. See also Morgan, Figure 3.10, pp. 82-83. @@ -596,6 +596,10 @@ add_noreturn_fake_exit_edges (void) void connect_infinite_loops_to_exit (void) { + /* First add fake exits to noreturn blocks, this is required to + discover only truly infinite loops below. */ + add_noreturn_fake_exit_edges (); + /* Perform depth-first search in the reverse graph to find nodes reachable from the exit block. */ depth_first_search dfs; -- cgit v1.1