Skip to content

Commit c4029c3

Browse files
committed
[KeyInstr][Clang] Agg init atom
This patch is part of a stack that teaches Clang to generate Key Instructions metadata for C and C++. The Key Instructions project is introduced, including a "quick summary" section at the top which adds context for this PR, here: https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668 The feature is only functional in LLVM if LLVM is built with CMake flag LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be removed. The Clang-side work is demoed here: #130943
1 parent d45f1d0 commit c4029c3

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

clang/lib/CodeGen/CGDecl.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,8 @@ void CodeGenFunction::emitStoresForConstant(const VarDecl &D, Address Loc,
12701270
createUnnamedGlobalForMemcpyFrom(
12711271
CGM, D, Builder, constant, Loc.getAlignment()),
12721272
SizeVal, isVolatile);
1273+
addInstToCurrentSourceAtom(I, nullptr);
1274+
12731275
if (IsAutoInit)
12741276
I->addAnnotationMetadata("auto-init");
12751277
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
// RUN: %clang -gkey-instructions %s -gmlt -S -emit-llvm -o - \
3+
// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank
4+
5+
// The implicit-check-not is important; we don't want the GEPs created for the
6+
// store locations to be included in the atom group.
7+
8+
int g;
9+
void a() {
10+
// CHECK: _Z1av()
11+
// CHECK: call void @llvm.memcpy{{.*}}, !dbg [[G1R1:!.*]]
12+
int A[] = { 1, 2, 3 };
13+
// CHECK: store i32 1, ptr %{{.*}}, !dbg [[G2R1:!.*]]
14+
// CHECK: store i32 2, ptr %{{.*}}, !dbg [[G2R1]]
15+
// CHECK: %0 = load i32, ptr @g{{.*}}, !dbg [[G2R2:!.*]]
16+
// CHECK: store i32 %0, ptr %{{.*}}, !dbg [[G2R1]]
17+
int B[] = { 1, 2, g };
18+
}
19+
20+
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
21+
// CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
22+
// CHECK: [[G2R2]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 2)

0 commit comments

Comments
 (0)