]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-ssa-ccp.c (maybe_fold_stmt_indirect): Do not mess with TREE_THIS_VOLATILE on...
authorRichard Guenther <rguenther@suse.de>
Wed, 20 Aug 2008 15:58:47 +0000 (15:58 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 20 Aug 2008 15:58:47 +0000 (15:58 +0000)
2008-08-20  Richard Guenther  <rguenther@suse.de>

* tree-ssa-ccp.c (maybe_fold_stmt_indirect): Do not mess
with TREE_THIS_VOLATILE on shared nodes.
(fold_stmt_r): Likewise.

* gcc.c-torture/compile/20080820-1.c: New testcase.

From-SVN: r139325

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/20080820-1.c [new file with mode: 0644]
gcc/tree-ssa-ccp.c

index 446bf4faf4524de33d3cd3da6fccdb0ea2a0bc53..940cec6215e4ff0311656b11d042b770cb8f29c2 100644 (file)
@@ -1,3 +1,9 @@
+2008-08-20  Richard Guenther  <rguenther@suse.de>
+
+       * tree-ssa-ccp.c (maybe_fold_stmt_indirect): Do not mess
+       with TREE_THIS_VOLATILE on shared nodes.
+       (fold_stmt_r): Likewise.
+
 2008-08-20  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/37171
index bda7ff1766ced3dc10b3ca01e5620996d256e6ac..fd849c4c17c00ca46b57c14b34eea9746a6ce195 100644 (file)
@@ -1,3 +1,7 @@
+2008-08-20  Richard Guenther  <rguenther@suse.de>
+
+       * gcc.c-torture/compile/20080820-1.c: New testcase.
+
 2008-08-20  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/37171
diff --git a/gcc/testsuite/gcc.c-torture/compile/20080820-1.c b/gcc/testsuite/gcc.c-torture/compile/20080820-1.c
new file mode 100644 (file)
index 0000000..a4d4375
--- /dev/null
@@ -0,0 +1,5 @@
+extern unsigned long volatile jiffies;
+void do_timer(void)
+{
+  (*(unsigned long *)&jiffies)++;
+}
index ad6012e8ffc7b13146fb0fa53eb222f05d114001..c89bd2cda949e7ae791c7926fbf5b980909a477e 100644 (file)
@@ -2118,7 +2118,11 @@ maybe_fold_stmt_indirect (tree expr, tree base, tree offset)
                                          TREE_TYPE (expr));
       if (t)
        {
-         TREE_THIS_VOLATILE (t) = volatile_p;
+         /* Preserve volatileness of the original expression.
+            We can end up with a plain decl here which is shared
+            and we shouldn't mess with its flags.  */
+         if (!SSA_VAR_P (t))
+           TREE_THIS_VOLATILE (t) = volatile_p;
          return t;
        }
     }
@@ -2404,8 +2408,11 @@ fold_stmt_r (tree *expr_p, int *walk_subtrees, void *data)
 
   if (t)
     {
-      /* Preserve volatileness of the original expression.  */
-      TREE_THIS_VOLATILE (t) = volatile_p;
+      /* Preserve volatileness of the original expression.
+        We can end up with a plain decl here which is shared
+        and we shouldn't mess with its flags.  */
+      if (!SSA_VAR_P (t))
+       TREE_THIS_VOLATILE (t) = volatile_p;
       *expr_p = t;
       *changed_p = true;
     }