[llvm-branch-commits] [clang] clang: Emit the "debugger-tuning" module flag (PR #235050)

Matt Arsenault via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sat Oct 24 01:40:48 PDT 2026


https://github.com/arsenm updated https://github.com/llvm/llvm-project/pull/235050

>From 52361c6d23b19846fe8875e3ce595a8acc32a0ae Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Thu, 1 Oct 2026 01:03:16 +0200
Subject: [PATCH] clang: Emit the "debugger-tuning" module flag

Co-authored-by: Claude Sonnet 5 <noreply at anthropic.com>
---
 clang/lib/CodeGen/CodeGenModule.cpp       |  3 +++
 clang/test/CodeGen/debugger-tuning-flag.c | 21 +++++++++++++++++++++
 2 files changed, 24 insertions(+)
 create mode 100644 clang/test/CodeGen/debugger-tuning-flag.c

diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index eec4d9e714abe..ce084487a6982 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1508,6 +1508,9 @@ void CodeGenModule::Release() {
                             llvm::getExceptionModelName(ExceptionModel)));
   }
 
+  if (CodeGenOpts.getDebuggerTuning() != llvm::DebuggerKind::Default)
+    getModule().setDebuggerTuning(CodeGenOpts.getDebuggerTuning());
+
   if (getTriple().isOSzOS()) {
     getModule().addModuleFlag(llvm::Module::Warning,
                               "zos_product_major_version",
diff --git a/clang/test/CodeGen/debugger-tuning-flag.c b/clang/test/CodeGen/debugger-tuning-flag.c
new file mode 100644
index 0000000000000..64167a3b513bb
--- /dev/null
+++ b/clang/test/CodeGen/debugger-tuning-flag.c
@@ -0,0 +1,21 @@
+// Verify clang emits the "debugger-tuning" module flag whenever a tuning is
+// specified.
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -debugger-tuning=gdb -emit-llvm %s -o - | FileCheck -check-prefix=GDB %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -debugger-tuning=lldb -emit-llvm %s -o - | FileCheck -check-prefix=LLDB %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -debugger-tuning=sce -emit-llvm %s -o - | FileCheck -check-prefix=SCE %s
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -debugger-tuning=dbx -emit-llvm %s -o - | FileCheck -check-prefix=DBX %s
+
+// A requested tuning that matches the target default is still recorded
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -debugger-tuning=lldb -emit-llvm %s -o - | FileCheck -check-prefix=LLDB %s
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck -check-prefix=DEFAULT %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - | FileCheck -check-prefix=DEFAULT %s
+
+void f(void) {}
+
+// GDB: !{i32 2, !"debugger-tuning", !"gdb"}
+// LLDB: !{i32 2, !"debugger-tuning", !"lldb"}
+// SCE: !{i32 2, !"debugger-tuning", !"sce"}
+// DBX: !{i32 2, !"debugger-tuning", !"dbx"}
+// DEFAULT-NOT: "debugger-tuning"



More information about the llvm-branch-commits mailing list