[llvm-branch-commits] [clang] [KeyInstr][Clang] Member initalization atom (PR #134640)
Orlando Cazalet-Hyams via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed May 21 07:25:28 PDT 2025
https://github.com/OCHyams updated https://github.com/llvm/llvm-project/pull/134640
>From 2fc4653e3e2bd825114b8081df06696c0f2b6b43 Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams <orlando.hyams at sony.com>
Date: Thu, 3 Apr 2025 17:00:09 +0100
Subject: [PATCH 1/2] [KeyInstr][Clang] Member initalization 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/CGClass.cpp | 1 +
.../DebugInfo/KeyInstructions/init-member.cpp | 22 +++++++++++++++++++
2 files changed, 23 insertions(+)
create mode 100644 clang/test/DebugInfo/KeyInstructions/init-member.cpp
diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index 6beb2bccfeae0..251b059c256f6 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/lib/CodeGen/CGClass.cpp
@@ -1338,6 +1338,7 @@ void CodeGenFunction::EmitCtorPrologue(const CXXConstructorDecl *CD,
assert(!Member->isBaseInitializer());
assert(Member->isAnyMemberInitializer() &&
"Delegating initializer on non-delegating constructor");
+ ApplyAtomGroup Grp(getDebugInfo());
CM.addMemberInitializer(Member);
}
CM.finish();
diff --git a/clang/test/DebugInfo/KeyInstructions/init-member.cpp b/clang/test/DebugInfo/KeyInstructions/init-member.cpp
new file mode 100644
index 0000000000000..60949bd8a604a
--- /dev/null
+++ b/clang/test/DebugInfo/KeyInstructions/init-member.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang -gkey-instructions %s -gmlt -S -emit-llvm -o - \
+// RUN: | FileCheck %s
+
+struct B {
+ float y;
+};
+
+class Cls {
+ public:
+ int x = 1;
+ B b = {5.f};
+};
+
+void fun() {
+ Cls c;
+}
+
+// CHECK: store i32 1, ptr %x{{.*}}, !dbg [[G1R1:!.*]]
+// CHECK: store float 5.000000e+00, ptr %y{{.*}}, !dbg [[G2R1:!.*]]
+
+// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
+// CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
>From 58f7f4d5dc33d81e0726c6dc332dd2842f821efb Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams <orlando.hyams at sony.com>
Date: Wed, 21 May 2025 15:25:17 +0100
Subject: [PATCH 2/2] cc1
---
clang/test/DebugInfo/KeyInstructions/init-member.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/test/DebugInfo/KeyInstructions/init-member.cpp b/clang/test/DebugInfo/KeyInstructions/init-member.cpp
index 60949bd8a604a..5ccefd4064421 100644
--- a/clang/test/DebugInfo/KeyInstructions/init-member.cpp
+++ b/clang/test/DebugInfo/KeyInstructions/init-member.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang -gkey-instructions %s -gmlt -S -emit-llvm -o - \
+// RUN: %clang_cc1 -gkey-instructions %s -debug-info-kind=line-tables-only -emit-llvm -o - \
// RUN: | FileCheck %s
struct B {
More information about the llvm-branch-commits
mailing list