]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
fix latent bootstrap-debug issue
authorAlexandre Oliva <oliva@adacore.com>
Sat, 28 Aug 2021 03:40:14 +0000 (00:40 -0300)
committerAlexandre Oliva <oliva@gnu.org>
Sat, 28 Aug 2021 03:40:14 +0000 (00:40 -0300)
I've hit a bootstrap-debug error involving large subprograms in
gcc/ada/sem_ch12.adb.  I'm afraid I couldn't narrow it down to a
reasonable testcase.

thread1 made different decisions about a block containing a
builtin_eh_filter call because in one compilation, estimate_num_insns
found a cgraph_node for the builtin and could thus get to the
is_simple_builtin test, but in the other it didn't.  With different
insn counts, one stage jump-threaded and the other didn't, and the
resulting code diverged quite a bit.

The reason the builtin had a cgraph_node in one case but not the other
was that modref got a chance to analyze the builtin call when it was
the first stmt in the block, and that created the cgraph_node.
However, when it was preceded by debug stmts, the loop in
analyze_function was cut short after the first debug stmt, because the
summary so far was not useful.

This patch fixes both issues: skip debug stmts in the analyze_function
loop, so as to prevent them from affecting any decisions in the loop,
and enable the insn count estimator to get to the is_simple_builtin
test when a cgraph_node has not been created for the builtin.

for  gcc/ChangeLog

* ipa-modref.c (analyze_function): Skip debug stmts.
* tree-inline.c (estimate_num_insn): Consider builtins even
without a cgraph_node.

gcc/ipa-modref.c
gcc/tree-inline.c

index 6e7788efb01acc382d43147afe2f7e95b59585e7..6d49cc1410e87cbab854a848c1db2ee3fe4058c3 100644 (file)
@@ -2125,7 +2125,8 @@ analyze_function (function *f, bool ipa)
   FOR_EACH_BB_FN (bb, f)
     {
       gimple_stmt_iterator si;
-      for (si = gsi_after_labels (bb); !gsi_end_p (si); gsi_next (&si))
+      for (si = gsi_start_nondebug_after_labels_bb (bb);
+          !gsi_end_p (si); gsi_next_nondebug (&si))
        {
          if (!analyze_stmt (summary, summary_lto,
                             gsi_stmt (si), ipa, &recursive_calls)
index 5955ff18fdbc5bac9236c2a0bcede769eea6e1aa..5e50e8013e2af3b1ab6f9b45f6421a8933f23dc2 100644 (file)
@@ -4436,8 +4436,8 @@ estimate_num_insns (gimple *stmt, eni_weights *weights)
            /* Do not special case builtins where we see the body.
               This just confuse inliner.  */
            struct cgraph_node *node;
-           if (!(node = cgraph_node::get (decl))
-               || node->definition)
+           if ((node = cgraph_node::get (decl))
+               && node->definition)
              ;
            /* For buitins that are likely expanded to nothing or
               inlined do not account operand costs.  */