Skip to content

Commit 76a55d3

Browse files
authored
[KeyInstr][Clang] Scalar init atom (#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 491619a commit 76a55d3

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
@@ -1925,6 +1925,7 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) {
19251925

19261926
const VarDecl &D = *emission.Variable;
19271927
auto DL = ApplyDebugLocation::CreateDefaultArtificial(*this, D.getLocation());
1928+
ApplyAtomGroup Grp(getDebugInfo());
19281929
QualType type = D.getType();
19291930

19301931
// 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
@@ -2222,6 +2222,8 @@ void CodeGenFunction::EmitStoreOfScalar(llvm::Value *Value, Address Addr,
22222222
}
22232223

22242224
llvm::StoreInst *Store = Builder.CreateStore(Value, Addr, Volatile);
2225+
addInstToCurrentSourceAtom(Store, Value);
2226+
22252227
if (isNontemporal) {
22262228
llvm::MDNode *Node =
22272229
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)