Skip to content

Commit 1f1f1d5

Browse files
committed
shouldUseBZeroPlusStoresToInitialize
1 parent 06b9688 commit 1f1f1d5

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

clang/lib/CodeGen/CGDecl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,7 @@ void CodeGenFunction::emitStoresForInitAfterBZero(llvm::Constant *Init,
938938
isa<llvm::ConstantVector>(Init) || isa<llvm::BlockAddress>(Init) ||
939939
isa<llvm::ConstantExpr>(Init)) {
940940
auto *I = Builder.CreateStore(Init, Loc, isVolatile);
941+
addInstToCurrentSourceAtom(I, nullptr);
941942
if (IsAutoInit)
942943
I->addAnnotationMetadata("auto-init");
943944
return;
@@ -1193,6 +1194,8 @@ void CodeGenFunction::emitStoresForConstant(const VarDecl &D, Address Loc,
11931194
if (shouldUseBZeroPlusStoresToInitialize(constant, ConstantSize)) {
11941195
auto *I = Builder.CreateMemSet(Loc, llvm::ConstantInt::get(CGM.Int8Ty, 0),
11951196
SizeVal, isVolatile);
1197+
addInstToCurrentSourceAtom(I, nullptr);
1198+
11961199
if (IsAutoInit)
11971200
I->addAnnotationMetadata("auto-init");
11981201

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,32 @@
11

2-
// RUN: %clang -gkey-instructions %s -gmlt -S -emit-llvm -o - \
2+
// RUN: %clang -gkey-instructions %s -gmlt -gno-column-info -S -emit-llvm -o - \
33
// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank
44

55
// The implicit-check-not is important; we don't want the GEPs created for the
66
// store locations to be included in the atom group.
77

88
int g;
9+
char gc;
910
void a() {
1011
// CHECK: _Z1av()
1112
// CHECK: call void @llvm.memcpy{{.*}}, !dbg [[G1R1:!.*]]
1213
int A[] = { 1, 2, 3 };
14+
1315
// CHECK: store i32 1, ptr %{{.*}}, !dbg [[G2R1:!.*]]
1416
// CHECK: store i32 2, ptr %{{.*}}, !dbg [[G2R1]]
1517
// CHECK: %0 = load i32, ptr @g{{.*}}, !dbg [[G2R2:!.*]]
1618
// CHECK: store i32 %0, ptr %{{.*}}, !dbg [[G2R1]]
1719
int B[] = { 1, 2, g };
20+
21+
// CHECK: call void @llvm.memset{{.*}}, !dbg [[G3R1:!.*]]
22+
// CHECK: store i8 97{{.*}}, !dbg [[G3R1]]
23+
// CHECK: store i8 98{{.*}}, !dbg [[G3R1]]
24+
// CHECK: store i8 99{{.*}}, !dbg [[G3R1]]
25+
// CHECK: store i8 100{{.*}}, !dbg [[G3R1]]
26+
char big[65536] = { 'a', 'b', 'c', 'd' };
1827
}
1928

2029
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
2130
// CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
2231
// CHECK: [[G2R2]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 2)
32+
// CHECK: [[G3R1]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 1)

0 commit comments

Comments
 (0)