public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] middle-end/93273 - fix sinking clobbers across backedges
@ 2020-01-15 13:19 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2020-01-15 13:19 UTC (permalink / raw)
  To: gcc-patches


The previous work to fix PR93199 didn't take into account backedges
when defering insertion.  The following simply avoids to defer in that
case since we know we'll not take secondary opportunities there.

Bootstrap & regtest on x86_64-unknown-linux-gnu in progress.

Richard.

2020-01-15  Richard Biener  <rguenther@suse.de>

        PR middle-end/93273
        * tree-eh.c (sink_clobbers): If we already visited the destination
        block do not defer insertion.
        (pass_lower_eh_dispatch::execute): Maintain BB_VISITED for
        the purpose of defered insertion.

	* g++.dg/torture/pr93273.C: New testcase.
---
 gcc/ChangeLog                          |  8 ++++++++
 gcc/testsuite/ChangeLog                |  5 +++++
 gcc/testsuite/g++.dg/torture/pr93273.C | 12 ++++++++++++
 gcc/tree-eh.c                          |  4 +++-
 4 files changed, 28 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/torture/pr93273.C

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8ef85773d7a..a4d772b1c69 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2020-01-15  Richard Biener  <rguenther@suse.de>
+
+	PR middle-end/93273
+	* tree-eh.c (sink_clobbers): If we already visited the destination
+	block do not defer insertion.
+	(pass_lower_eh_dispatch::execute): Maintain BB_VISITED for
+	the purpose of defered insertion.
+
 2020-01-15  Richard Biener  <rguenther@suse.de>
 
 	* alias.c (record_alias_subset): Avoid redundant work when
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 879d7b1d4a3..7ab3e33c134 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2020-01-15  Richard Biener  <rguenther@suse.de>
+
+	PR middle-end/93273
+	* g++.dg/torture/pr93273.C: New testcase.
+
 2020-01-15  Joseph Myers  <joseph@codesourcery.com>
 
 	PR c/93072
diff --git a/gcc/testsuite/g++.dg/torture/pr93273.C b/gcc/testsuite/g++.dg/torture/pr93273.C
new file mode 100644
index 00000000000..229642b5456
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr93273.C
@@ -0,0 +1,12 @@
+// { dg-do compile }
+
+void _setjmp(void *);
+struct S { ~S(); };
+void * (* fn)();
+void f();
+void g()
+{
+  S s;
+  _setjmp(fn());
+  []{ f(); }();
+}
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index dc80f574a2c..454b22cddec 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -3622,7 +3622,7 @@ sink_clobbers (basic_block bb,
 
   gimple *first_sunk = NULL;
   gimple *last_sunk = NULL;
-  if (sunk)
+  if (sunk && !(succbb->flags & BB_VISITED))
     dgsi = gsi_start (sunk[succbb->index]);
   else
     dgsi = gsi_after_labels (succbb);
@@ -3910,6 +3910,7 @@ pass_lower_eh_dispatch::execute (function *fun)
 	  else if (!any_resx_to_process)
 	    sink_clobbers (bb, NULL, &any_resx_to_process);
 	}
+      bb->flags &= ~BB_VISITED;
     }
   if (redirected)
     {
@@ -3940,6 +3941,7 @@ pass_lower_eh_dispatch::execute (function *fun)
 	      gsi_insert_seq_before (&gsi, sunk[bb->index], GSI_NEW_STMT);
 	      sunk[bb->index] = NULL;
 	    }
+	  bb->flags |= BB_VISITED;
 	}
       free (rpo);
       free (sunk);
-- 
2.16.4

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-01-15 12:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-15 13:19 [PATCH] middle-end/93273 - fix sinking clobbers across backedges 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).