From: Richard Smith Date: Thu, 19 Jul 2018 23:24:41 +0000 (+0000) Subject: Fix typo causing assert in self-host. X-Git-Tag: llvmorg-7.0.0-rc1~1023 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4c6568869e8a362f544d1c7996fe7be2c738a64b;p=platform%2Fupstream%2Fllvm.git Fix typo causing assert in self-host. llvm-svn: 337508 --- diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp index afe2bfe..cfd0b85 100644 --- a/clang/lib/CodeGen/CGExprConstant.cpp +++ b/clang/lib/CodeGen/CGExprConstant.cpp @@ -664,7 +664,7 @@ EmitArrayConstant(CodeGenModule &CGM, const ConstantArrayType *DestType, // struct of two arrays (the nonzero data and the zeroinitializer). if (CommonElementType && NonzeroLength >= 8) { llvm::Constant *Initial = llvm::ConstantArray::get( - llvm::ArrayType::get(CommonElementType, ArrayBound), + llvm::ArrayType::get(CommonElementType, NonzeroLength), makeArrayRef(Elements).take_front(NonzeroLength)); Elements.resize(2); Elements[0] = Initial; diff --git a/clang/test/CodeGen/init.c b/clang/test/CodeGen/init.c index 770995f..0353ba8 100644 --- a/clang/test/CodeGen/init.c +++ b/clang/test/CodeGen/init.c @@ -86,6 +86,17 @@ const char large_array_with_zeroes[1000] = { 'a', 'b', 'c', 1, 2, 3, 'x', 'y', 'z', 'z', 'y', [20] = 'q' }; +char global; + +// CHECK-DAG: @large_array_with_zeroes_2 = global <{ [10 x i8*], [90 x i8*] }> <{ [10 x i8*] [i8* null, i8* null, i8* null, i8* null, i8* null, i8* null, i8* null, i8* null, i8* null, i8* @global], [90 x i8*] zeroinitializer }> +const void *large_array_with_zeroes_2[100] = { + [9] = &global +}; +// CHECK-DAG: @large_array_with_zeroes_3 = global <{ [10 x i8*], [990 x i8*] }> <{ [10 x i8*] [i8* null, i8* null, i8* null, i8* null, i8* null, i8* null, i8* null, i8* null, i8* null, i8* @global], [990 x i8*] zeroinitializer }> +const void *large_array_with_zeroes_3[1000] = { + [9] = &global +}; + // PR279 comment #3 char test8(int X) { char str[100000] = "abc"; // tail should be memset.