]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR rtl-optimization/58365 (likely wrong code bug)
authorJakub Jelinek <jakub@redhat.com>
Wed, 7 May 2014 16:04:44 +0000 (18:04 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 7 May 2014 16:04:44 +0000 (18:04 +0200)
Backported from mainline
2013-09-10  Jakub Jelinek  <jakub@redhat.com>

PR rtl-optimization/58365
* cfgcleanup.c (merge_memattrs): Also clear MEM_READONLY_P
resp. MEM_NOTRAP_P if they differ, or set MEM_VOLATILE_P if
it differs.

* gcc.c-torture/execute/pr58365.c: New test.

From-SVN: r210173

gcc/ChangeLog
gcc/cfgcleanup.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr58365.c [new file with mode: 0644]

index 04f46d76a402f2c285bcdb592d8324d84bfd2292..139a579103a8670ad5d5608b195d7297b09fb34e 100644 (file)
@@ -1,6 +1,13 @@
 2014-05-07  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2013-09-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/58365
+       * cfgcleanup.c (merge_memattrs): Also clear MEM_READONLY_P
+       resp. MEM_NOTRAP_P if they differ, or set MEM_VOLATILE_P if
+       it differs.
+
        2013-08-30  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/58277
index 6ff161425fe76df7996c73971cd96e6d44b4541d..fae3aa656e574bf8f85ff6db91d4c5f2989c0efc 100644 (file)
@@ -922,6 +922,24 @@ merge_memattrs (rtx x, rtx y)
          set_mem_align (y, MEM_ALIGN (x));
        }
     }
+  if (code == MEM)
+    {
+      if (MEM_READONLY_P (x) != MEM_READONLY_P (y))
+       {
+         MEM_READONLY_P (x) = 0;
+         MEM_READONLY_P (y) = 0;
+       }
+      if (MEM_NOTRAP_P (x) != MEM_NOTRAP_P (y))
+       {
+         MEM_NOTRAP_P (x) = 0;
+         MEM_NOTRAP_P (y) = 0;
+       }
+      if (MEM_VOLATILE_P (x) != MEM_VOLATILE_P (y))
+       {
+         MEM_VOLATILE_P (x) = 1;
+         MEM_VOLATILE_P (y) = 1;
+       }
+    }
 
   fmt = GET_RTX_FORMAT (code);
   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
index b93701aa74f5eb708094f60226c4ada9fb1698f6..362317863b6107552a74520e136f59e10f7d2ab0 100644 (file)
@@ -1,6 +1,11 @@
 2014-05-07  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2013-09-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/58365
+       * gcc.c-torture/execute/pr58365.c: New test.
+
        2013-09-09  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/58325
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr58365.c b/gcc/testsuite/gcc.c-torture/execute/pr58365.c
new file mode 100644 (file)
index 0000000..1e6079d
--- /dev/null
@@ -0,0 +1,35 @@
+/* PR rtl-optimization/58365 */
+
+extern void abort (void);
+
+struct S
+{
+  volatile int a;
+  int b, c, d, e;
+} f;
+static struct S g, h;
+int i = 1;
+
+char
+foo (void)
+{
+  return i;
+}
+
+static struct S
+bar (void)
+{
+  if (foo ())
+    return f;
+  return g;
+}
+
+int
+main ()
+{
+  h = bar ();
+  f.b = 1;
+  if (h.b != 0)
+    abort ();
+  return 0;
+}