https://github.com/OCHyams updated https://github.com/llvm/llvm-project/pull/134648
>From 76d8a4306760fba28fc22c936b46d98263c37971 Mon Sep 17 00:00:00 2001 From: Orlando Cazalet-Hyams <orlando.hy...@sony.com> Date: Thu, 3 Apr 2025 19:57:39 +0100 Subject: [PATCH 1/3] [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: https://github.com/llvm/llvm-project/pull/130943 --- clang/lib/CodeGen/CGExpr.cpp | 3 ++- clang/test/DebugInfo/KeyInstructions/bitfield.cpp | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 clang/test/DebugInfo/KeyInstructions/bitfield.cpp diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 2c0edd69d96e9..e72288ccd3c26 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..0586050ba8397 --- /dev/null +++ b/clang/test/DebugInfo/KeyInstructions/bitfield.cpp @@ -0,0 +1,13 @@ +// RUN: %clang -gkey-instructions %s -gmlt -gcolumn-info -S -emit-llvm -o - \ +// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank + +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) >From d64c34ffe83820895a8a2487dc9e72abbc16b85c Mon Sep 17 00:00:00 2001 From: Orlando Cazalet-Hyams <orlando.hy...@sony.com> Date: Wed, 21 May 2025 15:55:29 +0100 Subject: [PATCH 2/3] cc1 --- clang/test/DebugInfo/KeyInstructions/bitfield.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/test/DebugInfo/KeyInstructions/bitfield.cpp b/clang/test/DebugInfo/KeyInstructions/bitfield.cpp index 0586050ba8397..b76e6ec3d9c99 100644 --- a/clang/test/DebugInfo/KeyInstructions/bitfield.cpp +++ b/clang/test/DebugInfo/KeyInstructions/bitfield.cpp @@ -1,4 +1,4 @@ -// RUN: %clang -gkey-instructions %s -gmlt -gcolumn-info -S -emit-llvm -o - \ +// RUN: %clang_cc1 -gkey-instructions %s -debug-info-kind=line-tables-only -emit-llvm -o - \ // RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank struct S { int a:3; }; >From 9cfcd16fe1db7b6663b8abbcd9d797d3bbbad713 Mon Sep 17 00:00:00 2001 From: Orlando Cazalet-Hyams <orlando.hy...@sony.com> Date: Tue, 27 May 2025 13:30:44 +0100 Subject: [PATCH 3/3] triple and test comment --- clang/test/DebugInfo/KeyInstructions/bitfield.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/clang/test/DebugInfo/KeyInstructions/bitfield.cpp b/clang/test/DebugInfo/KeyInstructions/bitfield.cpp index b76e6ec3d9c99..a14b4fbaf5854 100644 --- a/clang/test/DebugInfo/KeyInstructions/bitfield.cpp +++ b/clang/test/DebugInfo/KeyInstructions/bitfield.cpp @@ -1,6 +1,9 @@ -// RUN: %clang_cc1 -gkey-instructions %s -debug-info-kind=line-tables-only -emit-llvm -o - \ +// 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) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits