From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] tree-optimization/106938 - cleanup abnormal edges after inlining
Date: Wed, 14 Sep 2022 14:50:01 +0200 (CEST) [thread overview]
Message-ID: <20220914125001.E5607134B3@imap2.suse-dmz.suse.de> (raw)
After inlining and IPA transforms we run fixup_cfg to fixup CFG
effects in other functions. But that fails to clean abnormal
edges from non-pure/const calls which might no longer be necessary
when ->calls_setjmp is false. The following ensures this happens
and refactors things so we call EH/abnormal cleanup only on the
last stmt in a block.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
PR tree-optimization/106938
* tree-cfg.cc (execute_fixup_cfg): Purge dead abnormal
edges for all last stmts in a block. Do EH cleanup
only on the last stmt in a block.
* gcc.dg/pr106938.c: New testcase.
---
gcc/testsuite/gcc.dg/pr106938.c | 36 +++++++++++++++++++++++++++++++++
gcc/tree-cfg.cc | 13 ++++++------
2 files changed, 43 insertions(+), 6 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/pr106938.c
diff --git a/gcc/testsuite/gcc.dg/pr106938.c b/gcc/testsuite/gcc.dg/pr106938.c
new file mode 100644
index 00000000000..7365a8c29fb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr106938.c
@@ -0,0 +1,36 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -fno-ipa-pure-const -fno-tree-ccp -Wuninitialized" } */
+
+int n;
+
+void
+undefined (void);
+
+__attribute__ ((returns_twice)) int
+zero (void)
+{
+ return 0;
+}
+
+void
+bar (int)
+{
+ int i;
+
+ for (i = 0; i < -1; ++i)
+ n = 0;
+}
+
+__attribute__ ((simd)) void
+foo (void)
+{
+ int uninitialized;
+
+ undefined ();
+
+ while (uninitialized < 1) /* { dg-warning "uninitialized" } */
+ {
+ bar (zero ());
+ ++uninitialized;
+ }
+}
diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc
index 5cb6db337f9..48c5c4de51f 100644
--- a/gcc/tree-cfg.cc
+++ b/gcc/tree-cfg.cc
@@ -9828,16 +9828,12 @@ execute_fixup_cfg (void)
int flags = gimple_call_flags (stmt);
if (flags & (ECF_CONST | ECF_PURE | ECF_LOOPING_CONST_OR_PURE))
{
- if (gimple_purge_dead_abnormal_call_edges (bb))
- todo |= TODO_cleanup_cfg;
-
if (gimple_in_ssa_p (cfun))
{
todo |= TODO_update_ssa | TODO_cleanup_cfg;
update_stmt (stmt);
}
}
-
if (flags & ECF_NORETURN
&& fixup_noreturn_call (stmt))
todo |= TODO_cleanup_cfg;
@@ -9867,10 +9863,15 @@ execute_fixup_cfg (void)
}
}
- if (maybe_clean_eh_stmt (stmt)
+ gsi_next (&gsi);
+ }
+ if (gimple *last = last_stmt (bb))
+ {
+ if (maybe_clean_eh_stmt (last)
&& gimple_purge_dead_eh_edges (bb))
todo |= TODO_cleanup_cfg;
- gsi_next (&gsi);
+ if (gimple_purge_dead_abnormal_call_edges (bb))
+ todo |= TODO_cleanup_cfg;
}
/* If we have a basic block with no successors that does not
--
2.35.3
reply other threads:[~2022-09-14 12:50 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=20220914125001.E5607134B3@imap2.suse-dmz.suse.de \
--to=rguenther@suse.de \
--cc=gcc-patches@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).