summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTanya Lattner <tonic@nondot.org>2010-04-13 16:15:50 +0000
committerTanya Lattner <tonic@nondot.org>2010-04-13 16:15:50 +0000
commitf8f8dd3457acc13029c3a6e8a6ff8b28706354b3 (patch)
treed6e5f30a0428e7481825c3be5251a86a6698a155
parent1571f048734190c5ed03d1a6083e579ec7b5801f (diff)
downloadclang-release_27.tar.gz
Merge r101067 from mainline.release_27
fix PR6660/6168: emit padding as zeros instead of undef. Because trailing fields may not be represented in initializer lists, they are being handled as padding and those fields *must* be zero initialized. git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_27@101134 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/CGExprConstant.cpp6
-rw-r--r--test/CodeGen/decl.c19
-rw-r--r--test/CodeGen/union-init2.c5
3 files changed, 24 insertions, 6 deletions
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp
index f0d82a8f0d..5e2ff80a94 100644
--- a/lib/CodeGen/CGExprConstant.cpp
+++ b/lib/CodeGen/CGExprConstant.cpp
@@ -230,7 +230,7 @@ class ConstStructBuilder {
if (NumBytes > 1)
Ty = llvm::ArrayType::get(Ty, NumBytes);
- llvm::Constant *C = llvm::UndefValue::get(Ty);
+ llvm::Constant *C = llvm::Constant::getNullValue(Ty);
Elements.push_back(C);
assert(getAlignment(C) == 1 && "Padding must have 1 byte alignment!");
@@ -268,7 +268,7 @@ class ConstStructBuilder {
if (NumBytes > 1)
Ty = llvm::ArrayType::get(Ty, NumBytes);
- llvm::Constant *Padding = llvm::UndefValue::get(Ty);
+ llvm::Constant *Padding = llvm::Constant::getNullValue(Ty);
PackedElements.push_back(Padding);
ElementOffsetInBytes += getSizeInBytes(Padding);
}
@@ -508,7 +508,7 @@ public:
if (NumPadBytes > 1)
Ty = llvm::ArrayType::get(Ty, NumPadBytes);
- Elts.push_back(llvm::UndefValue::get(Ty));
+ Elts.push_back(llvm::Constant::getNullValue(Ty));
Types.push_back(Ty);
}
diff --git a/test/CodeGen/decl.c b/test/CodeGen/decl.c
index 6d068134b5..2b07be24fb 100644
--- a/test/CodeGen/decl.c
+++ b/test/CodeGen/decl.c
@@ -1,10 +1,11 @@
-// RUN: %clang_cc1 -emit-llvm < %s | FileCheck %s
+// RUN: %clang_cc1 -w -emit-llvm < %s | FileCheck %s
// CHECK: @test1.x = internal constant [12 x i32] [i32 1
// CHECK: @test2.x = internal constant [13 x i32] [i32 1,
-// CHECK: @test5w = global %0 { i32 2, [4 x i8] undef }
+// CHECK: @test5w = global %0 { i32 2, [4 x i8] zeroinitializer }
// CHECK: @test5y = global %union.test5u { double 7.300000e+0{{[0]*}}1 }
+// CHECK: @test6.x = internal constant %1 { i8 1, i8 2, i32 3, [4 x i8] zeroinitializer }
void test1() {
// This should codegen as a "@test1.x" global.
const int x[] = { 1, 2, 3, 4, 6, 8, 9, 10, 123, 231, 123,23 };
@@ -59,3 +60,17 @@ void test5() {
union test5u test5w = (union test5u)2;
union test5u test5y = (union test5u)73.0;
+
+
+// PR6660 - sqlite miscompile
+struct SelectDest {
+ unsigned char eDest;
+ unsigned char affinity;
+ int iParm;
+ int iMem;
+};
+
+void test6() {
+ struct SelectDest x = {1, 2, 3};
+ test6f(&x);
+}
diff --git a/test/CodeGen/union-init2.c b/test/CodeGen/union-init2.c
index ac469cd4b5..bd56f9e688 100644
--- a/test/CodeGen/union-init2.c
+++ b/test/CodeGen/union-init2.c
@@ -1,4 +1,7 @@
-// RUN: %clang_cc1 -emit-llvm %s -o - -triple i686-pc-linux-gnu | grep "bitcast (%0\* @r to %union.x\*), \[4 x i8\] undef"
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple i686-pc-linux-gnu | FileCheck %s
// Make sure we generate something sane instead of a ptrtoint
union x {long long b;union x* a;} r = {.a = &r};
+
+
+// CHECK: bitcast (%0* @r to %union.x*), [4 x i8] zero \ No newline at end of file