Patchwork Fix PR middle-end/45310

login
register
mail settings
Submitter Steven Bosscher
Date Dec. 17, 2010, 4:22 p.m.
Message ID <AANLkTi==kFA+je8xYeW3SsLO+h4ngfekUTe-rWknBU9q@mail.gmail.com>
Download mbox | patch
Permalink /patch/75921/
State New
Headers show

Comments

Steven Bosscher - Dec. 17, 2010, 4:22 p.m.
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
Richard Guenther - Dec. 18, 2010, 8:44 p.m.
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;
>        }
>
Steven Bosscher - Dec. 21, 2010, 2:58 p.m.
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

Patch

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;
        }