public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-6917] tree-optimization/104263 - avoid retaining abnormal edges for non-call/goto stmts
@ 2022-01-28 12:30 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2022-01-28 12:30 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:5b6f04276e3d1f20817ed37b2e26e43bd12cc0d2
commit r12-6917-g5b6f04276e3d1f20817ed37b2e26e43bd12cc0d2
Author: Richard Biener <rguenther@suse.de>
Date: Fri Jan 28 10:55:29 2022 +0100
tree-optimization/104263 - avoid retaining abnormal edges for non-call/goto stmts
This removes a premature optimization from
gimple_purge_dead_abnormal_call_edges which, after eliding the
last setjmp (or computed goto) statement from a function and
thus clearing cfun->calls_setjmp, leaves us with the abnormal
edges from other calls that are elided for example via inlining
or DCE. That's a CFG / IL combination that should be impossible
(not addressing the fact that with cfun->calls_setjmp and
cfun->has_nonlocal_label cleared we should not have any abnormal
edge at all).
For the testcase in the PR this means that IPA inlining will
remove the abormal edges from the block after inlining the call
the edge was coming from.
2022-01-28 Richard Biener <rguenther@suse.de>
PR tree-optimization/104263
* tree-cfg.cc (gimple_purge_dead_abnormal_call_edges):
Purge edges also when !cfun->has_nonlocal_label
and !cfun->calls_setjmp.
* gcc.dg/tree-ssa/inline-13.c: New testcase.
Diff:
---
gcc/testsuite/gcc.dg/tree-ssa/inline-13.c | 27 +++++++++++++++++++++++++++
gcc/tree-cfg.cc | 4 ----
2 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/inline-13.c b/gcc/testsuite/gcc.dg/tree-ssa/inline-13.c
new file mode 100644
index 00000000000..94d8a9c709e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/inline-13.c
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-early-inlining -fdump-tree-fixup_cfg3" } */
+
+int n;
+
+static int
+bar (void)
+{
+ int a;
+
+ n = 0;
+ a = 0;
+
+ return n;
+}
+
+__attribute__ ((pure, returns_twice)) int
+foo (void)
+{
+ n = bar () + 1;
+ foo ();
+
+ return 0;
+}
+
+/* Abnormal edges should be properly elided after IPA inlining of bar. */
+/* { dg-final { scan-tree-dump-times "bb" 1 "fixup_cfg3" } } */
diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc
index 77178a6bf69..efd10332c53 100644
--- a/gcc/tree-cfg.cc
+++ b/gcc/tree-cfg.cc
@@ -8915,10 +8915,6 @@ gimple_purge_dead_abnormal_call_edges (basic_block bb)
edge_iterator ei;
gimple *stmt = last_stmt (bb);
- if (!cfun->has_nonlocal_label
- && !cfun->calls_setjmp)
- return false;
-
if (stmt && stmt_can_make_abnormal_goto (stmt))
return false;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-01-28 12:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-28 12:30 [gcc r12-6917] tree-optimization/104263 - avoid retaining abnormal edges for non-call/goto stmts Richard Biener
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).