OSDN Git Service

2008-08-20 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 20 Aug 2008 15:58:47 +0000 (15:58 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 20 Aug 2008 15:58:47 +0000 (15:58 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@139325 138bc75d-0d04-0410-961f-82ee72b054a4

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 446bf4f..940cec6 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 bda7ff1..fd849c4 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 ad6012e..c89bd2c 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;
     }