On Thu, Feb 25, 2021 at 2:29 PM Richard Biener <rguent...@suse.de> wrote:
>
> 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.
>
> Boostrapped and tested on x86_64-unknown-linux-gnu, queued for stage1.

g:58ad6b2802592f1448eed48e8ad4e0e87985cecb

> 2021-02-25  Richard Biener  <rguent...@suse.de>
>
>         * 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 +++++++---
>  gcc/ipa-sra.c      |  1 -
>  gcc/predict.c      |  2 --
>  gcc/store-motion.c |  1 -
>  4 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/gcc/cfganal.c b/gcc/cfganal.c
> index 2627c2ff457..cec5abe30f9 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;
> diff --git a/gcc/ipa-sra.c b/gcc/ipa-sra.c
> index 1571921cb48..7a89906cee6 100644
> --- a/gcc/ipa-sra.c
> +++ b/gcc/ipa-sra.c
> @@ -2394,7 +2394,6 @@ process_scan_results (cgraph_node *node, struct 
> function *fun,
>             if (!pdoms_calculated)
>               {
>                 gcc_checking_assert (cfun);
> -               add_noreturn_fake_exit_edges ();
>                 connect_infinite_loops_to_exit ();
>                 calculate_dominance_info (CDI_POST_DOMINATORS);
>                 pdoms_calculated = true;
> diff --git a/gcc/predict.c b/gcc/predict.c
> index d0a8e5f8e04..0bf1748ffa8 100644
> --- a/gcc/predict.c
> +++ b/gcc/predict.c
> @@ -3106,7 +3106,6 @@ tree_estimate_probability (bool dry_run)
>  {
>    basic_block bb;
>
> -  add_noreturn_fake_exit_edges ();
>    connect_infinite_loops_to_exit ();
>    /* We use loop_niter_by_eval, which requires that the loops have
>       preheaders.  */
> @@ -4291,7 +4290,6 @@ rebuild_frequencies (void)
>    if (profile_status_for_fn (cfun) == PROFILE_GUESSED)
>      {
>        loop_optimizer_init (0);
> -      add_noreturn_fake_exit_edges ();
>        mark_irreducible_loops ();
>        connect_infinite_loops_to_exit ();
>        estimate_bb_frequencies (true);
> diff --git a/gcc/store-motion.c b/gcc/store-motion.c
> index f0401cae272..3f6e003219d 100644
> --- a/gcc/store-motion.c
> +++ b/gcc/store-motion.c
> @@ -1152,7 +1152,6 @@ one_store_motion_pass (void)
>
>    /* Now compute kill & transp vectors.  */
>    build_store_vectors ();
> -  add_noreturn_fake_exit_edges ();
>    connect_infinite_loops_to_exit ();
>
>    edge_list = pre_edge_rev_lcm (num_stores, st_transp, st_avloc,
> --
> 2.26.2

Reply via email to