From: Richard Guenther Date: Wed, 20 Aug 2008 15:58:47 +0000 (+0000) Subject: tree-ssa-ccp.c (maybe_fold_stmt_indirect): Do not mess with TREE_THIS_VOLATILE on... X-Git-Tag: releases/gcc-4.4.0~3010 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e2104f59c475b30f600bdd812904a508a2d15721;p=thirdparty%2Fgcc.git tree-ssa-ccp.c (maybe_fold_stmt_indirect): Do not mess with TREE_THIS_VOLATILE on shared nodes. 2008-08-20 Richard Guenther * 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 446bf4faf452..940cec6215e4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2008-08-20 Richard Guenther + + * 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 PR c/37171 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bda7ff1766ce..fd849c4c17c0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2008-08-20 Richard Guenther + + * gcc.c-torture/compile/20080820-1.c: New testcase. + 2008-08-20 Jakub Jelinek 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 index 000000000000..a4d4375ad2ee --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/20080820-1.c @@ -0,0 +1,5 @@ +extern unsigned long volatile jiffies; +void do_timer(void) +{ + (*(unsigned long *)&jiffies)++; +} diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index ad6012e8ffc7..c89bd2cda949 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -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; }