[clang] 9e07d0c - [KeyInstr][Clang] Bitfield atom (#134648)
via cfe-commits
cfe-commits at lists.llvm.org
Tue May 27 05:32:02 PDT 2025
Author: Orlando Cazalet-Hyams
Date: 2025-05-27T13:31:59+01:00
New Revision: 9e07d0cf60bd72da93e603233c732f8d0bd65f46
URL: https://github.com/llvm/llvm-project/commit/9e07d0cf60bd72da93e603233c732f8d0bd65f46
DIFF: https://github.com/llvm/llvm-project/commit/9e07d0cf60bd72da93e603233c732f8d0bd65f46.diff
LOG: [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.
Added:
clang/test/DebugInfo/KeyInstructions/bitfield.cpp
Modified:
clang/lib/CodeGen/CGExpr.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 700006db2a9c5..b82f4e9945777 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -2672,7 +2672,8 @@ void CodeGenFunction::EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst,
}
// Write the new value back out.
- Builder.CreateStore(SrcVal, Ptr, Dst.isVolatileQualified());
+ auto *I = Builder.CreateStore(SrcVal, Ptr, Dst.isVolatileQualified());
+ addInstToCurrentSourceAtom(I, SrcVal);
// Return the new value of the bit-field, if requested.
if (Result) {
diff --git a/clang/test/DebugInfo/KeyInstructions/bitfield.cpp b/clang/test/DebugInfo/KeyInstructions/bitfield.cpp
new file mode 100644
index 0000000000000..a14b4fbaf5854
--- /dev/null
+++ b/clang/test/DebugInfo/KeyInstructions/bitfield.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions %s -debug-info-kind=line-tables-only -emit-llvm -o - \
+// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank
+
+// Check assignments to bitfield members are given source atom groups, as this
+// has distinct codegen codepath to other variable/member assignments.
+
+struct S { int a:3; };
+
+void foo(int x, S s) {
+// CHECK: %bf.set = or i8 %bf.clear, %bf.value, !dbg [[G1R2:!.*]]
+// CHECK: store i8 %bf.set, ptr %s, align 4, !dbg [[G1R1:!.*]]
+ s.a = x;
+}
+
+// CHECK: [[G1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2)
+// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
More information about the cfe-commits
mailing list