This is the mail archive of the 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]

[patch] PR21847 (wrong-code with -fnon-call-exceptions)


This is a wrong-code bug caused by DCE, which removes dead statements
that may throw because of -fnon-call-exceptions.  For call exceptions
this is not a problem because we mark all CALL_EXPRs with side-effects
necessary (that obviously includes may-throw calls).  But a simple
assignment is not considered inherently necessary -- even if it may

The fix: With flag_non-call-exceptions set, mark all statements that
may throw as inherently necessary.

Only tested with a bubblestrap and by asserting that the test case now
passes.  I really honestly don't have time to test this better, so if
some Java hacker can help test this for GCC 4.0.1


	* tree-ssa-dce.c (mark_stmt_if_obviously_necessary): With
	-fnon-call-exceptions, also mark statements inherently
	necessary if they may throw.

Index: tree-ssa-dce.c
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-dce.c,v
retrieving revision 2.44
diff -u -3 -p -r2.44 tree-ssa-dce.c
--- tree-ssa-dce.c      1 Jun 2005 02:50:59 -0000       2.44
+++ tree-ssa-dce.c      5 Jun 2005 23:43:35 -0000
@@ -279,6 +279,15 @@ mark_stmt_if_obviously_necessary (tree s
   tree op, def;
   ssa_op_iter iter;

+  /* With non-call exceptions, we have to assume that all statements could
+     throw.  If a statement may throw, it is inherently necessary.  */
+  if (flag_non_call_exceptions
+      && tree_could_throw_p (stmt))
+    {
+      mark_stmt_necessary (stmt, true);
+      return;
+    }
   /* Statements that are implicitly live.  Most function calls, asm and return
      statements are required.  Labels and BIND_EXPR nodes are kept because
      they are control flow, and we have no way of knowing whether they can be

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