From: Andrew Pinski Date: Tue, 26 Jul 2011 05:28:45 +0000 (+0000) Subject: re PR middle-end/49671 (volatile goes missing after inlining) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0de204de65593f3a5cfeb4a682e0566657b840f6;p=gcc.git re PR middle-end/49671 (volatile goes missing after inlining) 2011-07-25 Andrew Pinski PR tree-opt/49671 * 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. 2011-07-25 Andrew Pinski PR tree-opt/49671 * gcc.dg/tree-ssa/pr49671-1.c: New testcase. * gcc.dg/tree-ssa/pr49671-2.c: New testcase. From-SVN: r176782 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b2ed72a61b3..c93e5e3890e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2011-07-25 Andrew Pinski + + PR tree-opt/49671 + * 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. + 2011-07-25 Richard Henderson * insn-notes.def (NOTE_INSN_CFA_RESTORE_STATE): Remove. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b90356962f8..dcaab877701 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2011-07-25 Andrew Pinski + + PR tree-opt/49671 + * gcc.dg/tree-ssa/pr49671-1.c: New testcase. + * gcc.dg/tree-ssa/pr49671-2.c: New testcase. + 2011-07-25 Rainer Orth * lib/target-supports.exp (check_effective_target_mmap): New proc. diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr49671-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr49671-1.c new file mode 100644 index 00000000000..acc9980dbda --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr49671-1.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +volatile int t; +static inline int cvmx_atomic_get32(volatile int *ptr) +{ + return *ptr; +} +void f(void) +{ + while (!cvmx_atomic_get32(&t)) + ; +} + +/* { dg-final { scan-tree-dump "\{v\}" "optimized" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ + + diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr49671-2.c b/gcc/testsuite/gcc.dg/tree-ssa/pr49671-2.c new file mode 100644 index 00000000000..ba5a9d99cf7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr49671-2.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +int t; +static inline int cvmx_atomic_get32(int *ptr) +{ + return *(volatile int*)ptr; +} +void f(void) +{ + while (!cvmx_atomic_get32(&t)) + ; +} + +/* { dg-final { scan-tree-dump "\{v\}" "optimized" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ + + diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 6a8eae86945..e9daff63cc3 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -881,14 +881,16 @@ remap_gimple_op_r (tree *tp, int *walk_subtrees, void *data) 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; diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index 6f784ee6489..cbebb81ba02 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -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++; } }