[llvm-commits] [llvm-gcc-4.2] r75715 - in /llvm-gcc-4.2/trunk/gcc: c-common.c c-typeck.c
Dale Johannesen
dalej at apple.com
Tue Jul 14 17:33:36 PDT 2009
Author: johannes
Date: Tue Jul 14 19:33:35 2009
New Revision: 75715
URL: http://llvm.org/viewvc/llvm-project?rev=75715&view=rev
Log:
The asm block code doesn't handle llvm's representation
of array refs with the extra ASM_EXPR over the array.
There is no particular reason to do this transformation
inside asm blocks, so just disable it.
gcc.apple/asm-block-{37,38,50}.c
Modified:
llvm-gcc-4.2/trunk/gcc/c-common.c
llvm-gcc-4.2/trunk/gcc/c-typeck.c
Modified: llvm-gcc-4.2/trunk/gcc/c-common.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/c-common.c?rev=75715&r1=75714&r2=75715&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/c-common.c (original)
+++ llvm-gcc-4.2/trunk/gcc/c-common.c Tue Jul 14 19:33:35 2009
@@ -2606,31 +2606,34 @@
#ifdef ENABLE_LLVM
}
- /* In LLVM we want to represent this as &P[i], not as P+i*sizeof(*P). */
- /* Convert the pointer to char* if it is a pointer to a zero sized object. */
- if (!size_set)
- ptrop = convert(build_pointer_type(char_type_node), ptrop);
-
- /* If the code is a subtract, construct 0-(ptrdiff_t)val. */
- if (resultcode == MINUS_EXPR)
- intop = build_binary_op (MINUS_EXPR,
- convert (ssizetype, integer_zero_node),
- convert (ssizetype, intop), 1);
- {
- tree arrayref, result, folded;
- arrayref = build4 (ARRAY_REF, TREE_TYPE(TREE_TYPE(ptrop)), ptrop, intop,
- NULL_TREE, NULL_TREE);
- result = build_unary_op (ADDR_EXPR, arrayref, 0);
-
- folded = fold (result);
- if (folded == result)
- TREE_CONSTANT (folded) = TREE_CONSTANT (ptrop) & TREE_CONSTANT (intop);
-
- /* If the original was void* + int, we converted it to char* + int. Convert
- back to the appropriate void* result and match type qualifiers. */
- if (!size_set || TYPE_QUALS(result_type) != TYPE_QUALS(TREE_TYPE(folded)))
- folded = convert(result_type, folded);
- return folded;
+ if (!inside_iasm_block) {
+ /* In LLVM we want to represent this as &P[i], not as P+i*sizeof(*P). */
+ /* Convert the pointer to char* if it is a pointer to a zero sized object.*/
+ if (!size_set)
+ ptrop = convert(build_pointer_type(char_type_node), ptrop);
+
+ /* If the code is a subtract, construct 0-(ptrdiff_t)val. */
+ if (resultcode == MINUS_EXPR)
+ intop = build_binary_op (MINUS_EXPR,
+ convert (ssizetype, integer_zero_node),
+ convert (ssizetype, intop), 1);
+ {
+ tree arrayref, result, folded;
+ arrayref = build4 (ARRAY_REF, TREE_TYPE(TREE_TYPE(ptrop)), ptrop, intop,
+ NULL_TREE, NULL_TREE);
+ result = build_unary_op (ADDR_EXPR, arrayref, 0);
+
+ folded = fold (result);
+ if (folded == result)
+ TREE_CONSTANT (folded) = TREE_CONSTANT (ptrop) & TREE_CONSTANT (intop);
+
+ /* If the original was void* + int, we converted it to char* + int.
+ Convert back to the appropriate void* result and match type
+ qualifiers. */
+ if (!size_set || TYPE_QUALS(result_type) != TYPE_QUALS(TREE_TYPE(folded)))
+ folded = convert(result_type, folded);
+ return folded;
+ }
}
#endif
/* LLVM LOCAL end */
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=75715&r1=75714&r2=75715&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/c-typeck.c (original)
+++ llvm-gcc-4.2/trunk/gcc/c-typeck.c Tue Jul 14 19:33:35 2009
@@ -3331,7 +3331,12 @@
/* LLVM LOCAL begin */
/* LLVM wants &x[y] to be kept as an &x[y] for better optimization. */
-#ifndef ENABLE_LLVM
+ /* However we shouldn't do this in asm blocks; we aren't going to be
+ doing anything complicated with addresses, and the asm block code
+ only understands array refs. */
+#ifdef ENABLE_LLVM
+ if (inside_iasm_block) {
+#endif
/* For &x[y], return x+y */
if (TREE_CODE (arg) == ARRAY_REF)
{
@@ -3344,6 +3349,8 @@
: op0),
TREE_OPERAND (arg, 1), 1);
}
+#ifdef ENABLE_LLVM
+ }
#endif
/* LLVM LOCAL end */
More information about the llvm-commits
mailing list