r224592 - Fix an address space id reset with array decay's
Pekka Jaaskelainen
pekka.jaaskelainen at tut.fi
Fri Dec 19 10:04:27 PST 2014
Author: pjaaskel
Date: Fri Dec 19 12:04:27 2014
New Revision: 224592
URL: http://llvm.org/viewvc/llvm-project?rev=224592&view=rev
Log:
Fix an address space id reset with array decay's
implicit conversion.
The issue was produced with OpenCL C code that
called a function with a constant string literal
argument.
Added:
cfe/trunk/test/CodeGenOpenCL/const-str-array-decay.cl
Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=224592&r1=224591&r2=224592&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Fri Dec 19 12:04:27 2014
@@ -1412,7 +1412,8 @@ Value *ScalarExprEmitter::VisitCastExpr(
if (!E->getType()->isVariableArrayType()) {
assert(isa<llvm::PointerType>(V->getType()) && "Expected pointer");
V = CGF.Builder.CreatePointerCast(
- V, ConvertType(E->getType())->getPointerTo());
+ V, ConvertType(E->getType())->getPointerTo(
+ V->getType()->getPointerAddressSpace()));
assert(isa<llvm::ArrayType>(V->getType()->getPointerElementType()) &&
"Expected pointer to array");
Added: cfe/trunk/test/CodeGenOpenCL/const-str-array-decay.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/const-str-array-decay.cl?rev=224592&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenOpenCL/const-str-array-decay.cl (added)
+++ cfe/trunk/test/CodeGenOpenCL/const-str-array-decay.cl Fri Dec 19 12:04:27 2014
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -ffake-address-space-map | FileCheck %s
+
+int test_func(constant char* foo);
+
+kernel void str_array_decy() {
+ test_func("Test string literal");
+}
+
+// CHECK: i8 addrspace(3)* getelementptr inbounds ([20 x i8] addrspace(3)*
+// CHECK-NOT: addrspacecast
+
More information about the cfe-commits
mailing list