Skip to content

Commit 5725d90

Browse files
committed
[KeyInstr][Clang] Coerced store atoms
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 a13e2d5 commit 5725d90

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

clang/lib/CodeGen/CGCall.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1432,7 +1432,8 @@ void CodeGenFunction::CreateCoercedStore(llvm::Value *Src, Address Dst,
14321432
for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
14331433
Address EltPtr = Builder.CreateStructGEP(Dst, i);
14341434
llvm::Value *Elt = Builder.CreateExtractValue(Src, i);
1435-
Builder.CreateStore(Elt, EltPtr, DstIsVolatile);
1435+
auto *I = Builder.CreateStore(Elt, EltPtr, DstIsVolatile);
1436+
addInstToCurrentSourceAtom(I, Elt);
14361437
}
14371438
} else {
14381439
Builder.CreateStore(Src, Dst.withElementType(SrcTy), DstIsVolatile);

clang/test/KeyInstructions/coerced.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// RUN: %clang -gkey-instructions -gno-column-info -x c++ %s -gmlt -S -emit-llvm -o - -target x86_64-unknown-linux \
2+
// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank
3+
4+
// RUN: %clang -gkey-instructions -gno-column-info -x c %s -gmlt -S -emit-llvm -o - -target x86_64-unknown-linux \
5+
// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank
6+
7+
typedef struct {
8+
void* a;
9+
void* b;
10+
} Struct;
11+
12+
Struct get();
13+
void store() {
14+
// CHECK: %1 = extractvalue { ptr, ptr } %call, 0, !dbg [[G1R2:!.*]]
15+
// CHECK: store ptr %1, ptr {{.*}}, !dbg [[G1R1:!.*]]
16+
// CHECK: %3 = extractvalue { ptr, ptr } %call, 1, !dbg [[G1R2]]
17+
// CHECK: store ptr %3, ptr {{.*}}, !dbg [[G1R1:!.*]]
18+
Struct s = get();
19+
// CHECK: ret void, !dbg [[G2R1:!.*]]
20+
}
21+
22+
// CHECK: [[G1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2)
23+
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
24+
// CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)

0 commit comments

Comments
 (0)