diff options
author | Chris Lattner <sabre@nondot.org> | 2010-04-13 18:16:19 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-04-13 18:16:19 +0000 |
commit | ff0e2a36e2574df7c5bb30ee491118b8007421c0 (patch) | |
tree | 183ba467fdea5faa80abf9b8ac5d16248f70dfab /clang/test/CodeGen/decl.c | |
parent | 0a2aff2d12ec21658516f19546c8cf3a6ef96ed9 (diff) | |
download | bcm5719-llvm-ff0e2a36e2574df7c5bb30ee491118b8007421c0.tar.gz bcm5719-llvm-ff0e2a36e2574df7c5bb30ee491118b8007421c0.zip |
Rework the ConstStructBuilder code to emit missing initializer
elements with explicit zero values instead of with tail padding.
On an example like this:
struct foo { int a; int b; };
struct foo fooarray[] = {
{1, 2},
{4},
};
We now lay this out as:
@fooarray = global [2 x %struct.foo] [%struct.foo { i32 1, i32 2 }, %struct.foo { i32 4, i32 0 }]
instead of as:
@fooarray = global %0 <{ %struct.foo { i32 1, i32 2 }, %1 { i32 4, [4 x i8] zeroinitializer } }>
Preserving both the struct type of the second element, but also the array type of the entire thing.
llvm-svn: 101155
Diffstat (limited to 'clang/test/CodeGen/decl.c')
-rw-r--r-- | clang/test/CodeGen/decl.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/clang/test/CodeGen/decl.c b/clang/test/CodeGen/decl.c index 2b07be24fbb..0c7ef5fc97f 100644 --- a/clang/test/CodeGen/decl.c +++ b/clang/test/CodeGen/decl.c @@ -5,7 +5,10 @@ // 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 } +// CHECK: @test6.x = internal constant %struct.SelectDest { i8 1, i8 2, i32 3, i32 0 } + +// CHECK: @test7 = global [2 x %struct.test7s] [%struct.test7s { i32 1, i32 2 }, %struct.test7s { i32 4, i32 0 }] + 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 }; @@ -74,3 +77,10 @@ void test6() { struct SelectDest x = {1, 2, 3}; test6f(&x); } + +// rdar://7657600 +struct test7s { int a; int b; } test7[] = { + {1, 2}, + {4}, +}; + |