public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR middle-end/45310
@ 2010-12-17 16:55 Steven Bosscher
  2010-12-18 23:35 ` Richard Guenther
  0 siblings, 1 reply; 3+ messages in thread
From: Steven Bosscher @ 2010-12-17 16:55 UTC (permalink / raw)
  To: GCC Patches, Richard Guenther

Hello,

When removing a statement, we should be removing it completely.

Bootstrapped and tested on ia64-unknown-linux-gnu. OK for trunk?

Ciao!
Steven


gcc/
        PR middle-end/45310
        * tree-ssa-phiprop.c (propagate_with_phi): Remove statement
        completely from the function, including EH traces.

testsuite/
        PR middle-end/45310
        * g++.dg/pr45310.C: New test.

I
Index: testsuite/g++.dg/pr45310.C
===================================================================
--- testsuite/g++.dg/pr45310.C  (revision 0)
+++ testsuite/g++.dg/pr45310.C  (revision 0)
@@ -0,0 +1,31 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -fnon-call-exceptions" }  */
+
+static inline const int &
+max (const int &a, const int &b)
+{
+  return a ? a : b;
+}
+
+static inline int
+baz ()
+{
+  return max (0, 0);
+}
+
+struct S
+{
+  ~S ()
+  {
+    baz ();
+  }
+};
+
+void bar ();
+void
+foo ()
+{
+  S s;
+  bar ();
+}
+
Index: tree-ssa-phiprop.c
===================================================================
--- tree-ssa-phiprop.c  (revision 167956)
+++ tree-ssa-phiprop.c  (working copy)
@@ -352,7 +352,7 @@ propagate_with_phi (basic_block bb, gimp
             want to delete it here we also have to delete all intermediate
             copies.  */
          gsi = gsi_for_stmt (use_stmt);
-         gsi_remove (&gsi, false);
+         gsi_remove (&gsi, true);

          phi_inserted = true;
        }

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

* Re: [PATCH] Fix PR middle-end/45310
  2010-12-17 16:55 [PATCH] Fix PR middle-end/45310 Steven Bosscher
@ 2010-12-18 23:35 ` Richard Guenther
  2010-12-21 15:58   ` Steven Bosscher
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Guenther @ 2010-12-18 23:35 UTC (permalink / raw)
  To: Steven Bosscher; +Cc: GCC Patches

On Fri, Dec 17, 2010 at 5:22 PM, Steven Bosscher <stevenb.gcc@gmail.com> wrote:
> Hello,
>
> When removing a statement, we should be removing it completely.
>
> Bootstrapped and tested on ia64-unknown-linux-gnu. OK for trunk?

Ick.  This means we also have to purge dead eh edges on the basic-block
and then run cfgcleanup if we did.  Similar adjustment needs to be
done a few lines below, we need to call maybe_clean_eh_stmt on
the modified stmt (and also cleanup dead eh edges).

The patch is ok as-is if you don't want to bother with all the above
corner-cases now (but it's probably not too difficult to construct other
similar testcases ;))

Thanks,
Richard.

> Ciao!
> Steven
>
>
> gcc/
>        PR middle-end/45310
>        * tree-ssa-phiprop.c (propagate_with_phi): Remove statement
>        completely from the function, including EH traces.
>
> testsuite/
>        PR middle-end/45310
>        * g++.dg/pr45310.C: New test.
>
> I
> Index: testsuite/g++.dg/pr45310.C
> ===================================================================
> --- testsuite/g++.dg/pr45310.C  (revision 0)
> +++ testsuite/g++.dg/pr45310.C  (revision 0)
> @@ -0,0 +1,31 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O1 -fnon-call-exceptions" }  */
> +
> +static inline const int &
> +max (const int &a, const int &b)
> +{
> +  return a ? a : b;
> +}
> +
> +static inline int
> +baz ()
> +{
> +  return max (0, 0);
> +}
> +
> +struct S
> +{
> +  ~S ()
> +  {
> +    baz ();
> +  }
> +};
> +
> +void bar ();
> +void
> +foo ()
> +{
> +  S s;
> +  bar ();
> +}
> +
> Index: tree-ssa-phiprop.c
> ===================================================================
> --- tree-ssa-phiprop.c  (revision 167956)
> +++ tree-ssa-phiprop.c  (working copy)
> @@ -352,7 +352,7 @@ propagate_with_phi (basic_block bb, gimp
>             want to delete it here we also have to delete all intermediate
>             copies.  */
>          gsi = gsi_for_stmt (use_stmt);
> -         gsi_remove (&gsi, false);
> +         gsi_remove (&gsi, true);
>
>          phi_inserted = true;
>        }
>

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

* Re: [PATCH] Fix PR middle-end/45310
  2010-12-18 23:35 ` Richard Guenther
@ 2010-12-21 15:58   ` Steven Bosscher
  0 siblings, 0 replies; 3+ messages in thread
From: Steven Bosscher @ 2010-12-21 15:58 UTC (permalink / raw)
  To: Richard Guenther; +Cc: GCC Patches

On Sat, Dec 18, 2010 at 9:44 PM, Richard Guenther
<richard.guenther@gmail.com> wrote:
> On Fri, Dec 17, 2010 at 5:22 PM, Steven Bosscher <stevenb.gcc@gmail.com> wrote:
>> Hello,
>>
>> When removing a statement, we should be removing it completely.
>>
>> Bootstrapped and tested on ia64-unknown-linux-gnu. OK for trunk?
>
> Ick.  This means we also have to purge dead eh edges on the basic-block
> and then run cfgcleanup if we did.  Similar adjustment needs to be
> done a few lines below, we need to call maybe_clean_eh_stmt on
> the modified stmt (and also cleanup dead eh edges).
>
> The patch is ok as-is if you don't want to bother with all the above
> corner-cases now (but it's probably not too difficult to construct other
> similar testcases ;))

I'll commit as-is because, quite frankly, I have no idea how this code works :-)

Ciao!
Steven

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

end of thread, other threads:[~2010-12-21 14:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-17 16:55 [PATCH] Fix PR middle-end/45310 Steven Bosscher
2010-12-18 23:35 ` Richard Guenther
2010-12-21 15:58   ` Steven Bosscher

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