Skip to content

Commit 1c670c0

Browse files
committed
[KeyInstr][Clang] Bitfield 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 2484a49 commit 1c670c0

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2614,7 +2614,8 @@ void CodeGenFunction::EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst,
26142614
}
26152615

26162616
// Write the new value back out.
2617-
Builder.CreateStore(SrcVal, Ptr, Dst.isVolatileQualified());
2617+
auto *I = Builder.CreateStore(SrcVal, Ptr, Dst.isVolatileQualified());
2618+
addInstToCurrentSourceAtom(I, SrcVal);
26182619

26192620
// Return the new value of the bit-field, if requested.
26202621
if (Result) {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: %clang -gkey-instructions %s -gmlt -gcolumn-info -S -emit-llvm -o - \
2+
// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank
3+
4+
struct S { int a:3; };
5+
6+
void foo(int x, S s) {
7+
// CHECK: %bf.set = or i8 %bf.clear, %bf.value, !dbg [[G1R2:!.*]]
8+
// CHECK: store i8 %bf.set, ptr %s, align 4, !dbg [[G1R1:!.*]]
9+
s.a = x;
10+
}
11+
12+
// CHECK: [[G1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2)
13+
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)

0 commit comments

Comments
 (0)