From 6809cbf90dffd5a6fccf96d67c5f520e1a162eb6 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Fri, 16 Jul 2004 15:28:29 -0700 Subject: [PATCH] basic-block.h (remove_fake_exit_edges): Declare. * basic-block.h (remove_fake_exit_edges): Declare. * cfganal.c (remove_fake_predecessors): Rename from remove_fake_successors; iterate over predecessors. (remove_fake_exit_edges): New. * cfgcleanup.c (try_optimize_cfg): Use it. * gcse.c (one_pre_gcse_pass, store_motion): Likewise. * predict.c (estimate_probability): Likewise. (tree_estimate_probability, note_prediction_to_br_prob): Likewise. * tree-cfg.c (make_edges): Likewise. * tree-ssa-pre.c (fini_pre): Likewise. * profile.c (instrument_edges): Don't remove_fake_edges. (branch_prob): Do it earlier here. From-SVN: r84840 --- gcc/ChangeLog | 15 +++++++++++++++ gcc/basic-block.h | 1 + gcc/cfganal.c | 24 ++++++++++++++++-------- gcc/cfgcleanup.c | 2 +- gcc/gcse.c | 4 ++-- gcc/predict.c | 6 +++--- gcc/profile.c | 5 ++--- gcc/tree-cfg.c | 2 +- gcc/tree-ssa-pre.c | 3 ++- 9 files changed, 43 insertions(+), 19 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a4a69f069db..df18afadb82 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,18 @@ +2004-07-16 Richard Henderson + + * basic-block.h (remove_fake_exit_edges): Declare. + * cfganal.c (remove_fake_predecessors): Rename from + remove_fake_successors; iterate over predecessors. + (remove_fake_exit_edges): New. + * cfgcleanup.c (try_optimize_cfg): Use it. + * gcse.c (one_pre_gcse_pass, store_motion): Likewise. + * predict.c (estimate_probability): Likewise. + (tree_estimate_probability, note_prediction_to_br_prob): Likewise. + * tree-cfg.c (make_edges): Likewise. + * tree-ssa-pre.c (fini_pre): Likewise. + * profile.c (instrument_edges): Don't remove_fake_edges. + (branch_prob): Do it earlier here. + 2004-07-16 Richard Henderson * tree-ssa-operands.c (get_expr_operands): Fix 2004-07-15 diff --git a/gcc/basic-block.h b/gcc/basic-block.h index e097f992543..e29b67aa9b9 100644 --- a/gcc/basic-block.h +++ b/gcc/basic-block.h @@ -417,6 +417,7 @@ extern void commit_edge_insertions (void); extern void commit_edge_insertions_watch_calls (void); extern void remove_fake_edges (void); +extern void remove_fake_exit_edges (void); extern void add_noreturn_fake_exit_edges (void); extern void connect_infinite_loops_to_exit (void); extern edge unchecked_make_edge (basic_block, basic_block, int); diff --git a/gcc/cfganal.c b/gcc/cfganal.c index 0bfccae79ec..db0238c68eb 100644 --- a/gcc/cfganal.c +++ b/gcc/cfganal.c @@ -51,7 +51,6 @@ static void flow_dfs_compute_reverse_add_bb (depth_first_search_ds, basic_block); static basic_block flow_dfs_compute_reverse_execute (depth_first_search_ds); static void flow_dfs_compute_reverse_finish (depth_first_search_ds); -static void remove_fake_successors (basic_block); static bool flow_active_insn_p (rtx); /* Like active_insn_p, except keep the return value clobber around @@ -529,20 +528,20 @@ flow_edge_list_print (const char *str, const edge *edge_list, int num_edges, FIL } -/* This routine will remove any fake successor edges for a basic block. - When the edge is removed, it is also removed from whatever predecessor +/* This routine will remove any fake predecessor edges for a basic block. + When the edge is removed, it is also removed from whatever successor list it is in. */ static void -remove_fake_successors (basic_block bb) +remove_fake_predecessors (basic_block bb) { edge e; - for (e = bb->succ; e;) + for (e = bb->pred; e;) { edge tmp = e; - e = e->succ_next; + e = e->pred_next; if ((tmp->flags & EDGE_FAKE) == EDGE_FAKE) remove_edge (tmp); } @@ -557,10 +556,19 @@ remove_fake_edges (void) { basic_block bb; - FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb) - remove_fake_successors (bb); + FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR->next_bb, NULL, next_bb) + remove_fake_predecessors (bb); } +/* This routine will remove all fake edges to the EXIT_BLOCK. */ + +void +remove_fake_exit_edges (void) +{ + remove_fake_predecessors (EXIT_BLOCK_PTR); +} + + /* This function will add a fake edge between any block which has no successors, and the exit block. Some data flow equations require these edges to exist. */ diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c index 9cccf0eb02c..f167800e21b 100644 --- a/gcc/cfgcleanup.c +++ b/gcc/cfgcleanup.c @@ -1978,7 +1978,7 @@ try_optimize_cfg (int mode) } if (mode & CLEANUP_CROSSJUMP) - remove_fake_edges (); + remove_fake_exit_edges (); clear_aux_for_blocks (); diff --git a/gcc/gcse.c b/gcc/gcse.c index d9773a14812..1d7212559b5 100644 --- a/gcc/gcse.c +++ b/gcc/gcse.c @@ -4964,7 +4964,7 @@ one_pre_gcse_pass (int pass) } free_ldst_mems (); - remove_fake_edges (); + remove_fake_exit_edges (); free_hash_table (&expr_hash_table); if (gcse_file) @@ -6858,7 +6858,7 @@ store_motion (void) free_store_memory (); free_edge_list (edge_list); - remove_fake_edges (); + remove_fake_exit_edges (); end_alias_analysis (); } diff --git a/gcc/predict.c b/gcc/predict.c index 08834f89cd9..49d2c612063 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -779,7 +779,7 @@ estimate_probability (struct loops *loops_info) && bb->succ->succ_next != NULL) combine_predictions_for_insn (BB_END (bb), bb); - remove_fake_edges (); + remove_fake_exit_edges (); /* Fill in the probability values in flowgraph based on the REG_BR_PROB notes. */ FOR_EACH_BB (bb) @@ -986,7 +986,7 @@ tree_estimate_probability (void) estimate_bb_frequencies (&loops_info); free_dominance_info (CDI_POST_DOMINATORS); - remove_fake_edges (); + remove_fake_exit_edges (); flow_loops_free (&loops_info); if (dump_file && (dump_flags & TDF_DETAILS)) dump_tree_cfg (dump_file, dump_flags); @@ -1220,7 +1220,7 @@ note_prediction_to_br_prob (void) free_dominance_info (CDI_DOMINATORS); free (heads); - remove_fake_edges (); + remove_fake_exit_edges (); } /* This is used to carry information about basic blocks. It is diff --git a/gcc/profile.c b/gcc/profile.c index 1d16b4368ac..ad62f87ccb4 100644 --- a/gcc/profile.c +++ b/gcc/profile.c @@ -139,8 +139,6 @@ instrument_edges (struct edge_list *el) int num_edges = NUM_EDGES (el); basic_block bb; - remove_fake_edges (); - FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb) { edge e; @@ -971,6 +969,8 @@ branch_prob (void) compute_value_histograms (n_values, values); } + remove_fake_edges (); + /* For each edge not on the spanning tree, add counting code. */ if (profile_arc_flag && coverage_counter_alloc (GCOV_COUNTER_ARCS, num_instrumented)) @@ -993,7 +993,6 @@ branch_prob (void) } } - remove_fake_edges (); free_aux_for_edges (); if (!ir_type ()) diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 6207fd31915..f6bb8e01b60 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -448,7 +448,7 @@ make_edges (void) /* We do not care about fake edges, so remove any that the CFG builder inserted for completeness. */ - remove_fake_edges (); + remove_fake_exit_edges (); /* Clean up the graph and warn for unreachable code. */ cleanup_tree_cfg (); diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index d6b19cd916a..ba4be7b82d3 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -1943,13 +1943,14 @@ fini_pre (void) free_alloc_pool (reference_node_pool); free_alloc_pool (unary_node_pool); htab_delete (phi_translate_table); - remove_fake_edges (); + remove_fake_exit_edges (); FOR_ALL_BB (bb) { free (bb->aux); bb->aux = NULL; } + free_dominance_info (CDI_POST_DOMINATORS); vn_delete (); } -- 2.30.2