]> granicus.if.org Git - clang/commitdiff
CodeGen: Fix invalid bitcast in partial initialization of automatic arrary variable
authorYaxun Liu <Yaxun.Liu@amd.com>
Mon, 23 Oct 2017 17:49:26 +0000 (17:49 +0000)
committerYaxun Liu <Yaxun.Liu@amd.com>
Mon, 23 Oct 2017 17:49:26 +0000 (17:49 +0000)
Differential Revision: https://reviews.llvm.org/D39184

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@316353 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDecl.cpp
test/CodeGenOpenCL/amdgcn-automatic-variable.cl

index 707f8a555cfec830f3d70b83b416cccf9eaf50d8..44a6db4750f5384b2f6d0f7a72b4533007339a0e 100644 (file)
@@ -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);
 
index 19287c7d8998fcc074caa2cd8179fe85e40df57b..fefe1c4a41d5016e09960ac80f0addbd0c49472e 100644 (file)
@@ -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.}};
+}