Hi,
There are two issues, first the inliner does not copy a volatile
when creating a new tree in one case. The second issue is that
IPA-SRA does not check if we are deferencing a pointer variable via a
volatile type.
OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
Thanks,
Andrew Pinski
ChangeLog:
* tree-inline.c (remap_gimple_op_r): Copy TREE_THIS_VOLATILE and
TREE_THIS_NOTRAP into the inner most MEM_REF.
Always copy TREE_THIS_VOLATILE.
* tree-sra.c (ptr_parm_has_direct_uses): Check that the lhs, rhs and
arguments are not volatile references.
Index: tree-sra.c
===================================================================
--- tree-sra.c (revision 176718)
+++ tree-sra.c (working copy)
@@ -3302,7 +3302,8 @@ ptr_parm_has_direct_uses (tree parm)
&& TREE_OPERAND (lhs, 0) == name
&& integer_zerop (TREE_OPERAND (lhs, 1))
&& types_compatible_p (TREE_TYPE (lhs),
- TREE_TYPE (TREE_TYPE (name))))
+ TREE_TYPE (TREE_TYPE (name)))
+ && !TREE_THIS_VOLATILE (lhs))
uses_ok++;
}
if (gimple_assign_single_p (stmt))
@@ -3314,7 +3315,8 @@ ptr_parm_has_direct_uses (tree parm)
&& TREE_OPERAND (rhs, 0) == name
&& integer_zerop (TREE_OPERAND (rhs, 1))
&& types_compatible_p (TREE_TYPE (rhs),
- TREE_TYPE (TREE_TYPE (name))))
+ TREE_TYPE (TREE_TYPE (name)))
+ && !TREE_THIS_VOLATILE (rhs))
uses_ok++;
}
else if (is_gimple_call (stmt))
@@ -3329,7 +3331,8 @@ ptr_parm_has_direct_uses (tree parm)
&& TREE_OPERAND (arg, 0) == name
&& integer_zerop (TREE_OPERAND (arg, 1))
&& types_compatible_p (TREE_TYPE (arg),
- TREE_TYPE (TREE_TYPE (name))))
+ TREE_TYPE (TREE_TYPE (name)))
+ && !TREE_THIS_VOLATILE (arg))
uses_ok++;
}
}
Index: tree-inline.c
===================================================================
--- tree-inline.c (revision 176718)
+++ tree-inline.c (working copy)
@@ -881,14 +881,16 @@ remap_gimple_op_r (tree *tp, int *walk_s
build_int_cst
(TREE_TYPE (TREE_OPERAND (*tp, 1)), 0));
*tp = tem;
+ TREE_THIS_VOLATILE (*tem_basep) = TREE_THIS_VOLATILE (old);
+ TREE_THIS_NOTRAP (*tem_basep) = TREE_THIS_NOTRAP (old);
}
else
{
*tp = fold_build2 (MEM_REF, type,
ptr, TREE_OPERAND (*tp, 1));
- TREE_THIS_VOLATILE (*tp) = TREE_THIS_VOLATILE (old);
TREE_THIS_NOTRAP (*tp) = TREE_THIS_NOTRAP (old);
}
+ TREE_THIS_VOLATILE (*tp) = TREE_THIS_VOLATILE (old);
TREE_NO_WARNING (*tp) = TREE_NO_WARNING (old);
*walk_subtrees = 0;
return NULL;