diff options
author | Yaxun Liu <Yaxun.Liu@amd.com> | 2017-10-23 17:49:26 +0000 |
---|---|---|
committer | Yaxun Liu <Yaxun.Liu@amd.com> | 2017-10-23 17:49:26 +0000 |
commit | 5d089284208206e4a621f99513a8a8ede1f9ac7e (patch) | |
tree | 0dd66f5a784f429774024ba0784c7ffaadc0b91b | |
parent | 8b07e281bf02e8cb4e598bc6cab958ee00d41a29 (diff) |
CodeGen: Fix invalid bitcast in partial initialization of automatic arrary variable
Differential Revision: https://reviews.llvm.org/D39184
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@316353 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/CGDecl.cpp | 2 | ||||
-rw-r--r-- | test/CodeGenOpenCL/amdgcn-automatic-variable.cl | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index 707f8a555c..44a6db4750 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -1266,7 +1266,7 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) { llvm::ConstantInt::get(IntPtrTy, getContext().getTypeSizeInChars(type).getQuantity()); - llvm::Type *BP = Int8PtrTy; + llvm::Type *BP = AllocaInt8PtrTy; if (Loc.getType() != BP) Loc = Builder.CreateBitCast(Loc, BP); diff --git a/test/CodeGenOpenCL/amdgcn-automatic-variable.cl b/test/CodeGenOpenCL/amdgcn-automatic-variable.cl index 19287c7d89..fefe1c4a41 100644 --- a/test/CodeGenOpenCL/amdgcn-automatic-variable.cl +++ b/test/CodeGenOpenCL/amdgcn-automatic-variable.cl @@ -58,3 +58,11 @@ void func2(void) { const int lvc = 4; lv1 = lvc; } + +// CHECK-LABEL: define void @func3() +// CHECK: %a = alloca [16 x [1 x float]], align 4, addrspace(5) +// CHECK: %[[CAST:.+]] = bitcast [16 x [1 x float]] addrspace(5)* %a to i8 addrspace(5)* +// CHECK: call void @llvm.memset.p5i8.i64(i8 addrspace(5)* %[[CAST]], i8 0, i64 64, i32 4, i1 false) +void func3(void) { + float a[16][1] = {{0.}}; +} |