[llvm-commits] [llvm-gcc-4.2] r64049 - in /llvm-gcc-4.2/trunk/gcc: c-typeck.c cp/typeck.c
Chris Lattner
sabre at nondot.org
Sat Feb 7 15:36:49 PST 2009
Author: lattner
Date: Sat Feb 7 17:36:49 2009
New Revision: 64049
URL: http://llvm.org/viewvc/llvm-project?rev=64049&view=rev
Log:
Fix some volatile handling issues with the array-ref hack. This fixes
PR3320 and test/FrontendC++/2009-02-07-VolatileArrayRefHack.cpp
Modified:
llvm-gcc-4.2/trunk/gcc/c-typeck.c
llvm-gcc-4.2/trunk/gcc/cp/typeck.c
Modified: llvm-gcc-4.2/trunk/gcc/c-typeck.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/c-typeck.c?rev=64049&r1=64048&r2=64049&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/c-typeck.c (original)
+++ llvm-gcc-4.2/trunk/gcc/c-typeck.c Sat Feb 7 17:36:49 2009
@@ -2131,8 +2131,14 @@
ty = TYPE_MAIN_VARIANT (ty);
ar = build4 (ARRAY_REF, ty, ar, index, NULL_TREE, NULL_TREE);
- /* mirror logic from build_indirect_ref to set TREE_THIS_VOLATILE. */
- TREE_THIS_VOLATILE(ar) = TYPE_VOLATILE(TREE_TYPE(ar));
+ /* Mirror logic from build_indirect_ref to set TREE_THIS_VOLATILE and other
+ * flags.
+ */
+ TREE_READONLY (ar) = TYPE_READONLY (TREE_TYPE (ar));
+ TREE_THIS_VOLATILE(ar) = TYPE_VOLATILE(TREE_TYPE (ar));
+ TREE_SIDE_EFFECTS (ar)
+ = TREE_THIS_VOLATILE (ar) || TREE_SIDE_EFFECTS (array) ||
+ TREE_SIDE_EFFECTS (index);
return ar;
}
#endif
Modified: llvm-gcc-4.2/trunk/gcc/cp/typeck.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/cp/typeck.c?rev=64049&r1=64048&r2=64049&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/cp/typeck.c (original)
+++ llvm-gcc-4.2/trunk/gcc/cp/typeck.c Sat Feb 7 17:36:49 2009
@@ -2581,13 +2581,23 @@
/* LLVM LOCAL begin */
#ifdef ENABLE_LLVM
- /* Do not create explicit pointer arithmetic for pointer subscripts,
+ /* Do not create explicit pointer arithmetic for pointer subscripts,
* instead, generate an array ref, even though the first argument is a
* pointer, not an array. The LLVM backend supports this use of ARRAY_REF
* and it provides it with more information for optimization.
*/
- return build4 (ARRAY_REF, TREE_TYPE(TREE_TYPE(ar)), ar, ind,
- NULL_TREE, NULL_TREE);
+ ar = build4 (ARRAY_REF, TREE_TYPE(TREE_TYPE(ar)), ar, ind,
+ NULL_TREE, NULL_TREE);
+ /* Mirror logic from build_indirect_ref to set TREE_THIS_VOLATILE and other
+ * flags.
+ */
+ TREE_THIS_VOLATILE (ar) = CP_TYPE_VOLATILE_P (TREE_TYPE (ar));
+ TREE_READONLY (ar) = CP_TYPE_CONST_P (TREE_TYPE (ar));
+ TREE_SIDE_EFFECTS (ar)
+ = TREE_THIS_VOLATILE (ar) || TREE_SIDE_EFFECTS (array) ||
+ TREE_SIDE_EFFECTS (idx);
+
+ return ar;
#endif
/* LLVM LOCAL end */
return build_indirect_ref (cp_build_binary_op (PLUS_EXPR, ar, ind),
More information about the llvm-commits
mailing list