]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[tree-prof] skip if errors were seen [PR113681]
authorAlexandre Oliva <oliva@adacore.com>
Wed, 12 Jun 2024 03:16:27 +0000 (00:16 -0300)
committerAlexandre Oliva <oliva@gnu.org>
Wed, 12 Jun 2024 03:16:27 +0000 (00:16 -0300)
ipa_tree_profile asserts that the symtab is in IPA_SSA state, but we
don't reach that state and ICE if e.g. ipa-strub passes report errors.
Skip this pass if errors were seen.

for  gcc/ChangeLog

PR tree-optimization/113681
* tree-profile.cc (pass_ipa_tree_profile::gate): Skip if
seen_errors.

for  gcc/testsuite/ChangeLog

PR tree-optimization/113681
* c-c++-common/strub-pr113681.c: New.

gcc/testsuite/c-c++-common/strub-pr113681.c [new file with mode: 0644]
gcc/tree-profile.cc

diff --git a/gcc/testsuite/c-c++-common/strub-pr113681.c b/gcc/testsuite/c-c++-common/strub-pr113681.c
new file mode 100644 (file)
index 0000000..3ef9017
--- /dev/null
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-options "-fstrub=relaxed -fbranch-probabilities" } */
+/* { dg-require-effective-target strub } */
+
+/* Same as torture/strub-inlineable1.c, but with -fbranch-probabilities, to
+   check that IPA tree-profiling won't ICE.  It would when we refrained from
+   running passes that would take it to IPA_SSA, but ran the pass that asserted
+   for IPA_SSA.  */
+
+inline void __attribute__ ((strub ("internal"), always_inline))
+inl_int_ali (void)
+{
+  /* No internal wrapper, so this body ALWAYS gets inlined,
+     but it cannot be called from non-strub contexts.  */
+}
+
+void
+bat (void)
+{
+  /* Not allowed, not a strub context.  */
+  inl_int_ali (); /* { dg-error "context" } */
+}
index b87c121790c99f4d296b11769c815d63f67e6437..e4bb689cef589e4c7a26a3b6cb3c793dfa9ab5c0 100644 (file)
@@ -2070,7 +2070,8 @@ pass_ipa_tree_profile::gate (function *)
      disabled.  */
   return (!in_lto_p && !flag_auto_profile
          && (flag_branch_probabilities || flag_test_coverage
-             || profile_arc_flag || condition_coverage_flag));
+             || profile_arc_flag || condition_coverage_flag)
+         && !seen_error ());
 }
 
 } // anon namespace