This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/32721] CCP removes volatile qualifiers.
- From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 13 Jul 2007 12:36:06 -0000
- Subject: [Bug tree-optimization/32721] CCP removes volatile qualifiers.
- References: <bug-32721-14766@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #6 from rguenth at gcc dot gnu dot org 2007-07-13 12:36 -------
Basically we could just make sure to preserve TREE_THIS_VOLATILE on folded
memory references *&spinlock[0] (where the indirect reference has this flag
set, but the result from maybe_fold_offset_to_reference, spinlock[0], has not),
and properly set has_volatile_ops on array references with TREE_THIS_VOLATILE
set. Like
Index: tree-ssa-ccp.c
===================================================================
*** tree-ssa-ccp.c (revision 126617)
--- tree-ssa-ccp.c (working copy)
*************** static tree
*** 1839,1844 ****
--- 1839,1845 ----
maybe_fold_stmt_indirect (tree expr, tree base, tree offset)
{
tree t;
+ bool volatile_p = TREE_THIS_VOLATILE (expr);
/* We may well have constructed a double-nested PLUS_EXPR via multiple
substitutions. Fold that down to one. Remove NON_LVALUE_EXPRs that
*************** maybe_fold_stmt_indirect (tree expr, tre
*** 1882,1888 ****
t = maybe_fold_offset_to_reference (base_addr, offset,
TREE_TYPE (expr));
if (t)
! return t;
}
else
{
--- 1883,1892 ----
t = maybe_fold_offset_to_reference (base_addr, offset,
TREE_TYPE (expr));
if (t)
! {
! TREE_THIS_VOLATILE (t) = volatile_p;
! return t;
! }
}
else
{
Index: tree-ssa-operands.c
===================================================================
--- tree-ssa-operands.c (revision 126617)
+++ tree-ssa-operands.c (working copy)
@@ -2078,6 +2078,9 @@ get_expr_operands (tree stmt, tree *expr
if (!none)
flags |= opf_no_vops;
+
+ if (TREE_THIS_VOLATILE (expr))
+ get_stmt_ann (stmt)->has_volatile_ops = true;
}
else if (TREE_CODE (ref) == INDIRECT_REF)
{
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32721