Skip to content

Commit 5364a99

Browse files
committed
[KeyInstr][Clang] Scalar init atom (llvm#134633)
This patch is part of a stack that teaches Clang to generate Key Instructions metadata for C and C++. RFC: 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.
1 parent 433a9be commit 5364a99

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

clang/lib/CodeGen/CGDecl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,6 +1917,7 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) {
19171917

19181918
const VarDecl &D = *emission.Variable;
19191919
auto DL = ApplyDebugLocation::CreateDefaultArtificial(*this, D.getLocation());
1920+
ApplyAtomGroup Grp(getDebugInfo());
19201921
QualType type = D.getType();
19211922

19221923
// If this local has an initializer, emit it now.

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2180,6 +2180,8 @@ void CodeGenFunction::EmitStoreOfScalar(llvm::Value *Value, Address Addr,
21802180
}
21812181

21822182
llvm::StoreInst *Store = Builder.CreateStore(Value, Addr, Volatile);
2183+
addInstToCurrentSourceAtom(Store, Value);
2184+
21832185
if (isNontemporal) {
21842186
llvm::MDNode *Node =
21852187
llvm::MDNode::get(Store->getContext(),
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// RUN: %clang_cc1 -gkey-instructions -x c++ %s -debug-info-kind=line-tables-only -emit-llvm -o - \
2+
// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank
3+
4+
// RUN: %clang_cc1 -gkey-instructions -x c %s -debug-info-kind=line-tables-only -emit-llvm -o - \
5+
// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank
6+
7+
void a() {
8+
// CHECK: store i32 0, ptr %A{{.*}}, !dbg [[G1R1:!.*]]
9+
int A = 0;
10+
// CHECK: %add = add {{.*}}, !dbg [[G2R2:!.*]]
11+
// CHECK: store i32 %add, ptr %B, align 4, !dbg [[G2R1:!.*]]
12+
int B = 2 * A + 1;
13+
}
14+
15+
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
16+
// CHECK: [[G2R2]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 2)
17+
// CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)

0 commit comments

Comments
 (0)