Skip to content

Commit 2535081

Browse files
committed
shouldUseBZeroPlusStoresToInitialize
1 parent fb71445 commit 2535081

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
@@ -945,6 +945,7 @@ void CodeGenFunction::emitStoresForInitAfterBZero(llvm::Constant *Init,
945945
isa<llvm::ConstantVector>(Init) || isa<llvm::BlockAddress>(Init) ||
946946
isa<llvm::ConstantExpr>(Init)) {
947947
auto *I = Builder.CreateStore(Init, Loc, isVolatile);
948+
addInstToCurrentSourceAtom(I, nullptr);
948949
if (IsAutoInit)
949950
I->addAnnotationMetadata("auto-init");
950951
return;
@@ -1200,6 +1201,8 @@ void CodeGenFunction::emitStoresForConstant(const VarDecl &D, Address Loc,
12001201
if (shouldUseBZeroPlusStoresToInitialize(constant, ConstantSize)) {
12011202
auto *I = Builder.CreateMemSet(Loc, llvm::ConstantInt::get(CGM.Int8Ty, 0),
12021203
SizeVal, isVolatile);
1204+
addInstToCurrentSourceAtom(I, nullptr);
1205+
12031206
if (IsAutoInit)
12041207
I->addAnnotationMetadata("auto-init");
12051208

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)