diff options
| author | Hans Wennborg <hans@hanshq.net> | 2018-05-23 08:24:01 +0000 |
|---|---|---|
| committer | Hans Wennborg <hans@hanshq.net> | 2018-05-23 08:24:01 +0000 |
| commit | 156349fa109f4cda503a10fff3f3bc07d395cb04 (patch) | |
| tree | 91154b0eae2dc9c20a88909a7ddc706adeeb4529 /clang/test | |
| parent | 1c0a15c4449f862711cb0df0548d4c83a6ff8554 (diff) | |
| download | bcm5719-llvm-156349fa109f4cda503a10fff3f3bc07d395cb04.tar.gz bcm5719-llvm-156349fa109f4cda503a10fff3f3bc07d395cb04.zip | |
Revert r333044 "Use zeroinitializer for (trailing zero portion of) large array initializers"
It caused asserts, see PR37560.
> Use zeroinitializer for (trailing zero portion of) large array initializers
> more reliably.
>
> Clang has two different ways it emits array constants (from InitListExprs and
> from APValues), and both had some ability to emit zeroinitializer, but neither
> was able to catch all cases where we could use zeroinitializer reliably. In
> particular, emitting from an APValue would fail to notice if all the explicit
> array elements happened to be zero. In addition, for large arrays where only an
> initial portion has an explicit initializer, we would emit the complete
> initializer (which could be huge) rather than emitting only the non-zero
> portion. With this change, when the element would have a suffix of more than 8
> zero elements, we emit the array constant as a packed struct of its initial
> portion followed by a zeroinitializer constant for the trailing zero portion.
>
> In passing, I found a bug where SemaInit would sometimes walk the entire array
> when checking an initializer that only covers the first few elements; that's
> fixed here to unblock testing of the rest.
>
> Differential Revision: https://reviews.llvm.org/D47166
llvm-svn: 333067
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/CodeGen/init.c | 10 | ||||
| -rw-r--r-- | clang/test/CodeGenCXX/cxx11-initializer-aggregate.cpp | 39 | ||||
| -rw-r--r-- | clang/test/SemaCXX/aggregate-initialization.cpp | 6 |
3 files changed, 0 insertions, 55 deletions
diff --git a/clang/test/CodeGen/init.c b/clang/test/CodeGen/init.c index 8403320ec69..9924662cddf 100644 --- a/clang/test/CodeGen/init.c +++ b/clang/test/CodeGen/init.c @@ -72,16 +72,6 @@ struct a7 { struct a7 test7 = { .b = 0, .v = "bar" }; -// CHECK-DAG: @huge_array = global {{.*}} <{ i32 1, i32 0, i32 2, i32 0, i32 3, [999999995 x i32] zeroinitializer }> -int huge_array[1000000000] = {1, 0, 2, 0, 3, 0, 0, 0}; - -// CHECK-DAG: @huge_struct = global {{.*}} { i32 1, <{ i32, [999999999 x i32] }> <{ i32 2, [999999999 x i32] zeroinitializer }> } -struct Huge { - int a; - int arr[1000 * 1000 * 1000]; -} huge_struct = {1, {2, 0, 0, 0}}; - - // PR279 comment #3 char test8(int X) { char str[100000] = "abc"; // tail should be memset. diff --git a/clang/test/CodeGenCXX/cxx11-initializer-aggregate.cpp b/clang/test/CodeGenCXX/cxx11-initializer-aggregate.cpp index 4a593689650..8bf35966f5b 100644 --- a/clang/test/CodeGenCXX/cxx11-initializer-aggregate.cpp +++ b/clang/test/CodeGenCXX/cxx11-initializer-aggregate.cpp @@ -11,13 +11,6 @@ namespace NonAggregateCopyInAggregateInit { // PR32044 struct C { A &&p; } c{{1}}; } -namespace NearlyZeroInit { - // CHECK-DAG: @_ZN14NearlyZeroInit1aE = global {{.*}} <{ i32 1, i32 2, i32 3, [120 x i32] zeroinitializer }> - int a[123] = {1, 2, 3}; - // CHECK-DAG: @_ZN14NearlyZeroInit1bE = global {{.*}} { i32 1, <{ i32, [2147483647 x i32] }> <{ i32 2, [2147483647 x i32] zeroinitializer }> } - struct B { int n; int arr[1024 * 1024 * 1024 * 2u]; } b = {1, {2}}; -} - // CHECK-LABEL: define {{.*}}@_Z3fn1i( int fn1(int x) { // CHECK: %[[INITLIST:.*]] = alloca %struct.A @@ -58,35 +51,3 @@ namespace NonTrivialInit { // meaningful. B b[30] = {}; } - -namespace ZeroInit { - enum { Zero, One }; - constexpr int zero() { return 0; } - constexpr int *null() { return nullptr; } - struct Filler { - int x; - Filler(); - }; - struct S1 { - int x; - }; - - // These declarations, if implemented elementwise, require huge - // amout of memory and compiler time. - unsigned char data_1[1024 * 1024 * 1024 * 2u] = { 0 }; - unsigned char data_2[1024 * 1024 * 1024 * 2u] = { Zero }; - unsigned char data_3[1024][1024][1024] = {{{0}}}; - unsigned char data_4[1024 * 1024 * 1024 * 2u] = { zero() }; - int *data_5[1024 * 1024 * 512] = { nullptr }; - int *data_6[1024 * 1024 * 512] = { null() }; - struct S1 data_7[1024 * 1024 * 512] = {{0}}; - char data_8[1000 * 1000 * 1000] = {}; - int (&&data_9)[1000 * 1000 * 1000] = {0}; - unsigned char data_10[1024 * 1024 * 1024 * 2u] = { 1 }; - unsigned char data_11[1024 * 1024 * 1024 * 2u] = { One }; - unsigned char data_12[1024][1024][1024] = {{{1}}}; - - // This variable must be initialized elementwise. - Filler data_e1[1024] = {}; - // CHECK: getelementptr inbounds {{.*}} @_ZN8ZeroInit7data_e1E -} diff --git a/clang/test/SemaCXX/aggregate-initialization.cpp b/clang/test/SemaCXX/aggregate-initialization.cpp index 0dfb61333ec..514473f9bcb 100644 --- a/clang/test/SemaCXX/aggregate-initialization.cpp +++ b/clang/test/SemaCXX/aggregate-initialization.cpp @@ -180,9 +180,3 @@ namespace IdiomaticStdArrayInitDoesNotWarn { #pragma clang diagnostic pop } - -namespace HugeArraysUseArrayFiller { - // All we're checking here is that initialization completes in a reasonable - // amount of time. - struct A { int n; int arr[1000 * 1000 * 1000]; } a = {1, {2}}; -} |

