Loading clang/lib/CodeGen/CGExprConstant.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -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!"); Loading Loading @@ -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); } Loading Loading @@ -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); } Loading clang/test/CodeGen/decl.c +17 −2 Original line number Diff line number Diff line // 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 }; Loading Loading @@ -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); } clang/test/CodeGen/union-init2.c +4 −1 Original line number Diff line number Diff line // 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 Loading
clang/lib/CodeGen/CGExprConstant.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -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!"); Loading Loading @@ -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); } Loading Loading @@ -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); } Loading
clang/test/CodeGen/decl.c +17 −2 Original line number Diff line number Diff line // 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 }; Loading Loading @@ -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); }
clang/test/CodeGen/union-init2.c +4 −1 Original line number Diff line number Diff line // 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