r337508 - Fix typo causing assert in self-host.
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 19 16:24:41 PDT 2018
Author: rsmith
Date: Thu Jul 19 16:24:41 2018
New Revision: 337508
URL: http://llvm.org/viewvc/llvm-project?rev=337508&view=rev
Log:
Fix typo causing assert in self-host.
Modified:
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/test/CodeGen/init.c
Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=337508&r1=337507&r2=337508&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Thu Jul 19 16:24:41 2018
@@ -664,7 +664,7 @@ EmitArrayConstant(CodeGenModule &CGM, co
// 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;
Modified: cfe/trunk/test/CodeGen/init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/init.c?rev=337508&r1=337507&r2=337508&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/init.c (original)
+++ cfe/trunk/test/CodeGen/init.c Thu Jul 19 16:24:41 2018
@@ -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.
More information about the cfe-commits
mailing list