Author: Matt Arsenault
Date: 2026-10-30T03:03:58Z
New Revision: 1787c8b10b4f5f33bc5268b57f3be21df2e3f108

URL: 
https://github.com/llvm/llvm-project/commit/1787c8b10b4f5f33bc5268b57f3be21df2e3f108
DIFF: 
https://github.com/llvm/llvm-project/commit/1787c8b10b4f5f33bc5268b57f3be21df2e3f108.diff

LOG: clang: Emit the "debugger-tuning" module flag (#235050)

Co-authored-by: Claude Sonnet 5 <[email protected]>

Added: 
    clang/test/CodeGen/debugger-tuning-flag.c

Modified: 
    clang/lib/CodeGen/CodeGenModule.cpp

Removed: 
    


################################################################################
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"


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to