]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR middle-end/45852 (volatile structs are broken!)
authorJakub Jelinek <jakub@redhat.com>
Sun, 16 Jan 2011 20:23:01 +0000 (21:23 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sun, 16 Jan 2011 20:23:01 +0000 (21:23 +0100)
Backport from mainline
2010-12-21  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/45852
* expr.c (store_expr): Ignore alt_rtl if equal to target,
but has side-effects.

* gcc.target/i386/pr45852.c: New test.

From-SVN: r168867

gcc/ChangeLog
gcc/expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr45852.c [new file with mode: 0644]

index db6b41f7575788a116d89cdc472f9f001400f943..9db1eae1c77df5b0fa5ee8ba393febba0c738ebb 100644 (file)
@@ -1,6 +1,12 @@
 2011-01-16  Jakub Jelinek  <jakub@redhat.com>
 
        Backport from mainline
+       2010-12-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/45852
+       * expr.c (store_expr): Ignore alt_rtl if equal to target,
+       but has side-effects.
+
        2010-12-16  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/43655
index db179bbf104eae07e80610b210b6ab7b67a10ac7..59b869048c1096dff3ec6623c1c6ad9cca356e8b 100644 (file)
@@ -4730,7 +4730,10 @@ store_expr (tree exp, rtx target, int call_param_p, bool nontemporal)
       /* If store_expr stores a DECL whose DECL_RTL(exp) == TARGET,
         but TARGET is not valid memory reference, TEMP will differ
         from TARGET although it is really the same location.  */
-      && !(alt_rtl && rtx_equal_p (alt_rtl, target))
+      && !(alt_rtl
+          && rtx_equal_p (alt_rtl, target)
+          && !side_effects_p (alt_rtl)
+          && !side_effects_p (target))
       /* If there's nothing to copy, don't bother.  Don't call
         expr_size unless necessary, because some front-ends (C++)
         expr_size-hook must not be given objects that are not
index b83af10d258a9166b2edf4c70be4b57d6ce4cac9..840b45323f2f1f2c7bb7ada89ac3cbef6a86b3f2 100644 (file)
@@ -1,6 +1,11 @@
 2011-01-16  Jakub Jelinek  <jakub@redhat.com>
 
        Backport from mainline
+       2010-12-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/45852
+       * gcc.target/i386/pr45852.c: New test.
+
        2010-12-16  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/43655
diff --git a/gcc/testsuite/gcc.target/i386/pr45852.c b/gcc/testsuite/gcc.target/i386/pr45852.c
new file mode 100644 (file)
index 0000000..b0ba093
--- /dev/null
@@ -0,0 +1,16 @@
+/* PR middle-end/45852 */
+/* { dg-options "-O2 -mcmodel=small" } */
+/* { dg-do compile { target { { i?86-*-linux* x86_64-*-linux* } && lp64 } } } */
+/* { dg-require-visibility "" } */
+
+struct S { int s; };
+
+volatile struct S globvar __attribute__((visibility ("hidden"))) = { -6 };
+
+void
+foo (void)
+{
+  globvar = globvar;
+}
+
+/* { dg-final { scan-assembler-times "globvar.%?rip" 2 } } */