OSDN Git Service

Backported from mainline
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 7 May 2014 16:04:44 +0000 (16:04 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 7 May 2014 16:04:44 +0000 (16:04 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@210173 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 04f46d7..139a579 100644 (file)
@@ -1,6 +1,13 @@
 2014-05-07  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
 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
        2013-08-30  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/58277
index 6ff1614..fae3aa6 100644 (file)
@@ -922,6 +922,24 @@ merge_memattrs (rtx x, rtx y)
          set_mem_align (y, MEM_ALIGN (x));
        }
     }
          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--)
 
   fmt = GET_RTX_FORMAT (code);
   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
index b93701a..3623178 100644 (file)
@@ -1,6 +1,11 @@
 2014-05-07  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
 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
        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;
+}