Skip to content

Commit 76d8a43

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 123bf5f commit 76d8a43

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
@@ -2672,7 +2672,8 @@ void CodeGenFunction::EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst,
26722672
}
26732673

26742674
// Write the new value back out.
2675-
Builder.CreateStore(SrcVal, Ptr, Dst.isVolatileQualified());
2675+
auto *I = Builder.CreateStore(SrcVal, Ptr, Dst.isVolatileQualified());
2676+
addInstToCurrentSourceAtom(I, SrcVal);
26762677

26772678
// Return the new value of the bit-field, if requested.
26782679
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)