This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [vtab (and trunk?)] fix fallout from SSA-coalescing user variables


On Oct 12, 2007, Alexandre Oliva <aoliva@redhat.com> wrote:

> On Oct 11, 2007, "Richard Guenther" <richard.guenther@gmail.com> wrote:
>> The extra checking triggers PR33735.

> Thanks.  This is an interesting testcase.  It is a variant of the
> problem H-P had reported, but I hadn't realized there was a lingering
> bug then.

So the patch below reverts the work around for H-P's testcase, and
fixes the problem explained below.

> The problem is that an exception thrown during stack unwinding is
> supposed to call terminate(), but AFAICT, when we inline the dtor of
> temporaries (other than the exception object) in the throw expression
> itself, calls that are brought in as part of the destructor get EH
> edges as if they were before the throw expression, escaping the
> requirement to call terminate in case they throw.

> Now, since there aren't edges from the original dtor call to enclosing
> catch or clean-up points, when we look for such edges at the time of
> adjusting the PHI nodes, we don't find them.  Oops.

The patch below recognizes an ERT_ALLOWED_EXCEPTIONS EH region with an
empty type list and prevents the enclosing try block from being
regarded as reachable from within.  With it, both testcases compile
correctly.

libstdc++ builds with it; starting bootstrap and regtesting on
x86_64-linux-gnu right now.  Ok to install?

for  gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	PR tree-optimization/33735
	PR tree-optimization/33572
	* tree-inline.c (update_ssa_across_abnormal_edges): Revert
	2007-10-09's change.
	* except.c (duplicate_eh_regions): Don't look for prev_try
	beyond ERT_ALLOWED_EXCEPTIONS with an empty list.
	
for  gcc/testsuite/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	PR tree-optimization/33735
	* g++.dg/torture/pr33735.C: New.

Index: gcc/tree-inline.c
===================================================================
--- gcc/tree-inline.c.orig	2007-10-13 04:38:25.000000000 -0300
+++ gcc/tree-inline.c	2007-10-13 05:47:02.000000000 -0300
@@ -1055,8 +1055,7 @@ update_ssa_across_abnormal_edges (basic_
 	      }
 
 	    re = find_edge (ret_bb, e->dest);
-	    if (!re)
-	      continue;
+	    gcc_assert (re);
 	    gcc_assert ((re->flags & (EDGE_EH | EDGE_ABNORMAL))
 			== (e->flags & (EDGE_EH | EDGE_ABNORMAL)));
 
Index: gcc/except.c
===================================================================
--- gcc/except.c.orig	2007-09-28 00:02:42.000000000 -0300
+++ gcc/except.c	2007-10-13 05:24:54.000000000 -0300
@@ -1005,7 +1005,9 @@ duplicate_eh_regions (struct function *i
     for (prev_try = VEC_index (eh_region, cfun->eh->region_array, outer_region);
          prev_try && prev_try->type != ERT_TRY;
 	 prev_try = prev_try->outer)
-      if (prev_try->type == ERT_MUST_NOT_THROW)
+      if (prev_try->type == ERT_MUST_NOT_THROW
+	  || (prev_try->type == ERT_ALLOWED_EXCEPTIONS
+	      && !prev_try->u.allowed.type_list))
 	{
 	  prev_try = NULL;
 	  break;
Index: gcc/testsuite/g++.dg/torture/pr33735.C
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ gcc/testsuite/g++.dg/torture/pr33735.C	2007-10-13 05:44:39.000000000 -0300
@@ -0,0 +1,21 @@
+// { dg-do compile }
+#include <string>
+typedef struct _ts { } PyThreadState;
+PyThreadState * Py_NewInterpreter(void);
+void Py_EndInterpreter(PyThreadState *);
+class ApplicationError {
+public:
+    ApplicationError(std::string errormsg) : errormsg(errormsg)  { }
+    std::string errormsg;
+};
+void run()
+{
+    PyThreadState *py_state=__null;
+    try {
+        if (!(py_state=Py_NewInterpreter()))
+            throw ApplicationError("error");
+    }
+    catch(ApplicationError e) {
+        Py_EndInterpreter(py_state);
+    }
+}
-- 
Alexandre Oliva         http://www.lsd.ic.unicamp.br/~oliva/
FSF Latin America Board Member         http://www.fsfla.org/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]