Skip to content

Commit 9e07d0c

Browse files
authored
[KeyInstr][Clang] Bitfield atom (#134648)
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 e573ffe commit 9e07d0c

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions %s -debug-info-kind=line-tables-only -emit-llvm -o - \
2+
// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank
3+
4+
// Check assignments to bitfield members are given source atom groups, as this
5+
// has distinct codegen codepath to other variable/member assignments.
6+
7+
struct S { int a:3; };
8+
9+
void foo(int x, S s) {
10+
// CHECK: %bf.set = or i8 %bf.clear, %bf.value, !dbg [[G1R2:!.*]]
11+
// CHECK: store i8 %bf.set, ptr %s, align 4, !dbg [[G1R1:!.*]]
12+
s.a = x;
13+
}
14+
15+
// CHECK: [[G1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2)
16+
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)

0 commit comments

Comments
 (0)