public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix tree-opt/33589 out of SSA not cleaning up eh info for statements
@ 2007-10-28 12:57 Andrew Pinski
  2007-10-28 13:14 ` Diego Novillo
  2007-10-28 13:38 ` Richard Guenther
  0 siblings, 2 replies; 3+ messages in thread
From: Andrew Pinski @ 2007-10-28 12:57 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 921 bytes --]

Hi,
  The problem here is that out of SSA (via TER) replaces the function
expression inside a CALL_EXPR with a nothrowing function.  So we go
from a possible throwing call to a call which is known not to throw.
But Out of SSA does not call maybe_clean_or_replace_eh_stmt to make
sure the eh information is updated so we get an ICE.

This fixes the problem by calling maybe_clean_or_replace_eh_stmt if
the expression changed.  We may as well also call
tree_purge_dead_eh_edges if maybe_clean_or_replace_eh_stmt returns
true also to cleanup the dead edges now instead of during
final_cleanup.

OK? Bootstrapped and tested on i386-apple-darwin8.10.1.

:ADDPATCH tree-opt:

Thanks,
Andrew Pinski

ChangeLog:
* tree-outof-ssa.c (rewrite_trees): If the statement changed, cleanup
the eh information on the statement.


* testsuite/g++.dg/torture/pr33589-1.C: New testcase.
* testsuite/g++.dg/torture/pr33589-2.C: New testcase.

[-- Attachment #2: fixpr33589.diff.txt --]
[-- Type: text/plain, Size: 1588 bytes --]

Index: testsuite/g++.dg/torture/pr33589-1.C
===================================================================
--- testsuite/g++.dg/torture/pr33589-1.C	(revision 0)
+++ testsuite/g++.dg/torture/pr33589-1.C	(revision 0)
@@ -0,0 +1,22 @@
+// { dg-do compile }
+struct base { void somemethod() {} };
+struct derived : public base { };
+
+struct smartpointer
+{
+  ~smartpointer() { }
+  operator derived*() const
+  {
+    return 0;
+  }
+};
+typedef void ( derived::* methodptr_type )();
+methodptr_type getmemberptr()
+{
+        return &derived::somemethod;
+}
+void somefunction()
+{
+        smartpointer pObj;
+        ( pObj->*getmemberptr() )();
+}
Index: testsuite/g++.dg/torture/pr33589-2.C
===================================================================
--- testsuite/g++.dg/torture/pr33589-2.C	(revision 0)
+++ testsuite/g++.dg/torture/pr33589-2.C	(revision 0)
@@ -0,0 +1,13 @@
+// { dg-do compile }
+
+void f(void*) throw();
+
+void somefunction()
+{
+try {
+   void (*g)(void*) = (void (*)(void*))f;
+   void (*g2)(int*) = (void (*)(int*))g;
+    g2(0);
+} catch (...)
+{throw;}
+}
Index: tree-outof-ssa.c
===================================================================
--- tree-outof-ssa.c	(revision 129695)
+++ tree-outof-ssa.c	(working copy)
@@ -758,7 +758,12 @@ rewrite_trees (var_map map, tree *values
 	  if (remove)
 	    bsi_remove (&si, true);
 	  else
-	    bsi_next (&si);
+	    {
+	      if (changed)
+		if (maybe_clean_or_replace_eh_stmt (stmt, stmt))
+		  tree_purge_dead_eh_edges (bb);
+	      bsi_next (&si);
+	    }
 	}
 
       phi = phi_nodes (bb);

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix tree-opt/33589 out of SSA not cleaning up eh info for statements
  2007-10-28 12:57 [PATCH] Fix tree-opt/33589 out of SSA not cleaning up eh info for statements Andrew Pinski
@ 2007-10-28 13:14 ` Diego Novillo
  2007-10-28 13:38 ` Richard Guenther
  1 sibling, 0 replies; 3+ messages in thread
From: Diego Novillo @ 2007-10-28 13:14 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: gcc-patches

On 10/28/07, Andrew Pinski <pinskia@gmail.com> wrote:

> * tree-outof-ssa.c (rewrite_trees): If the statement changed, cleanup
> the eh information on the statement.

OK.


Diego.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix tree-opt/33589 out of SSA not cleaning up eh info for statements
  2007-10-28 12:57 [PATCH] Fix tree-opt/33589 out of SSA not cleaning up eh info for statements Andrew Pinski
  2007-10-28 13:14 ` Diego Novillo
@ 2007-10-28 13:38 ` Richard Guenther
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Guenther @ 2007-10-28 13:38 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: gcc-patches

On 10/28/07, Andrew Pinski <pinskia@gmail.com> wrote:
> Hi,
>   The problem here is that out of SSA (via TER) replaces the function
> expression inside a CALL_EXPR with a nothrowing function.  So we go
> from a possible throwing call to a call which is known not to throw.
> But Out of SSA does not call maybe_clean_or_replace_eh_stmt to make
> sure the eh information is updated so we get an ICE.
>
> This fixes the problem by calling maybe_clean_or_replace_eh_stmt if
> the expression changed.  We may as well also call
> tree_purge_dead_eh_edges if maybe_clean_or_replace_eh_stmt returns
> true also to cleanup the dead edges now instead of during
> final_cleanup.
>
> OK? Bootstrapped and tested on i386-apple-darwin8.10.1.

Ok.

Thanks,
Richard.

> :ADDPATCH tree-opt:
>
> Thanks,
> Andrew Pinski
>
> ChangeLog:
> * tree-outof-ssa.c (rewrite_trees): If the statement changed, cleanup
> the eh information on the statement.
>
>
> * testsuite/g++.dg/torture/pr33589-1.C: New testcase.
> * testsuite/g++.dg/torture/pr33589-2.C: New testcase.
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-10-28 12:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-28 12:57 [PATCH] Fix tree-opt/33589 out of SSA not cleaning up eh info for statements Andrew Pinski
2007-10-28 13:14 ` Diego Novillo
2007-10-28 13:38 ` Richard Guenther

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).