public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Richard Biener <rguenth@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-5325] tree-optimization/108500 - avoid useless fast-query compute in CFG cleanup
Date: Tue, 24 Jan 2023 14:29:48 +0000 (GMT)	[thread overview]
Message-ID: <20230124142948.078003858D1E@sourceware.org> (raw)

https://gcc.gnu.org/g:f31fa9ea35ebcf221a2abaacba5511225f5d036e

commit r13-5325-gf31fa9ea35ebcf221a2abaacba5511225f5d036e
Author: Richard Biener <rguenther@suse.de>
Date:   Tue Jan 24 10:49:18 2023 +0100

    tree-optimization/108500 - avoid useless fast-query compute in CFG cleanup
    
    CFG cleanup computes dominators before the loop over blocks looking
    for merging opportunities.  That computes also the fast-query DFS
    numbers but that's a bit pointless since any CFG cleanup will invalidate
    them immediately (they are re-computed before fixing up loops).
    The following avoids this and fixes the SIGSEGV due to the deep
    recursion in assign_dfs_numbers after inlining very many small
    functions.
    
            PR tree-optimization/108500
            * dominance.h (calculate_dominance_info): Add parameter
            to indicate fast-query compute, defaulted to true.
            * dominance.cc (calculate_dominance_info): Honor
            fast-query compute parameter.
            * tree-cfgcleanup.cc (cleanup_tree_cfg_noloop): Do
            not compute the dominator fast-query DFS numbers.

Diff:
---
 gcc/dominance.cc       | 9 ++++++---
 gcc/dominance.h        | 2 +-
 gcc/tree-cfgcleanup.cc | 6 ++++--
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/gcc/dominance.cc b/gcc/dominance.cc
index 13d5498443b..099b8fd3f24 100644
--- a/gcc/dominance.cc
+++ b/gcc/dominance.cc
@@ -705,10 +705,12 @@ compute_dom_fast_query_in_region (enum cdi_direction dir,
 }
 
 /* The main entry point into this module.  DIR is set depending on whether
-   we want to compute dominators or postdominators.  */
+   we want to compute dominators or postdominators.  If COMPUTE_FAST_QUERY
+   is false then the DFS numbers allowing for a O(1) dominance query
+   are not computed.  */
 
 void
-calculate_dominance_info (cdi_direction dir)
+calculate_dominance_info (cdi_direction dir, bool compute_fast_query)
 {
   unsigned int dir_index = dom_convert_dir_to_idx (dir);
 
@@ -745,7 +747,8 @@ calculate_dominance_info (cdi_direction dir)
   else
     checking_verify_dominators (dir);
 
-  compute_dom_fast_query (dir);
+  if (compute_fast_query)
+    compute_dom_fast_query (dir);
 
   timevar_pop (TV_DOMINANCE);
 }
diff --git a/gcc/dominance.h b/gcc/dominance.h
index abdcf76e6f2..3c5a345f478 100644
--- a/gcc/dominance.h
+++ b/gcc/dominance.h
@@ -35,7 +35,7 @@ enum dom_state
   DOM_OK		/* Everything is ok.  */
 };
 
-extern void calculate_dominance_info (enum cdi_direction);
+extern void calculate_dominance_info (enum cdi_direction, bool = true);
 extern void calculate_dominance_info_for_region (enum cdi_direction,
 						 vec<basic_block>);
 extern void free_dominance_info (function *, enum cdi_direction);
diff --git a/gcc/tree-cfgcleanup.cc b/gcc/tree-cfgcleanup.cc
index ca0cb633f2c..64ff16fc45b 100644
--- a/gcc/tree-cfgcleanup.cc
+++ b/gcc/tree-cfgcleanup.cc
@@ -1106,9 +1106,11 @@ cleanup_tree_cfg_noloop (unsigned ssa_update_flags)
       timevar_push (TV_TREE_CLEANUP_CFG);
     }
 
-  /* Compute dominator info which we need for the iterative process below.  */
+  /* Compute dominator info which we need for the iterative process below.
+     Avoid computing the fast query DFS numbers since any block merging
+     done will invalidate them anyway.  */
   if (!dom_info_available_p (CDI_DOMINATORS))
-    calculate_dominance_info (CDI_DOMINATORS);
+    calculate_dominance_info (CDI_DOMINATORS, false);
   else
     checking_verify_dominators (CDI_DOMINATORS);

                 reply	other threads:[~2023-01-24 14:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230124142948.078003858D1E@sourceware.org \
    --to=rguenth@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).