[clang] [KeyInstr][Clang][NFC] Don't set -dwarf-use-key-instructions (PR #144115)

Orlando Cazalet-Hyams via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 30 00:44:23 PDT 2025


https://github.com/OCHyams updated https://github.com/llvm/llvm-project/pull/144115

>From 5ed1dedf639090e0706d25c874ebbb4335cc26f2 Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams <orlando.hyams at sony.com>
Date: Fri, 13 Jun 2025 17:39:53 +0100
Subject: [PATCH 1/3] [KeyInstr][Clang][NFC] Don't set
 -dwarf-use-key-instructions

Once #144104 lands the flag is true by default (because each DISubprogram will
track whether or not it's using key instructions).
---
 clang/lib/Driver/ToolChains/Clang.cpp         |  5 +----
 clang/test/DebugInfo/KeyInstructions/flag.cpp | 10 ++++++++--
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index ceb592d1548f5..fea4ee909ff46 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4631,11 +4631,8 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T,
   }
 
   if (Args.hasFlag(options::OPT_gkey_instructions,
-                   options::OPT_gno_key_instructions, false)) {
+                   options::OPT_gno_key_instructions, false))
     CmdArgs.push_back("-gkey-instructions");
-    CmdArgs.push_back("-mllvm");
-    CmdArgs.push_back("-dwarf-use-key-instructions");
-  }
 
   if (EmitCodeView) {
     CmdArgs.push_back("-gcodeview");
diff --git a/clang/test/DebugInfo/KeyInstructions/flag.cpp b/clang/test/DebugInfo/KeyInstructions/flag.cpp
index 93503dd4bdb4c..8ce140a2ca031 100644
--- a/clang/test/DebugInfo/KeyInstructions/flag.cpp
+++ b/clang/test/DebugInfo/KeyInstructions/flag.cpp
@@ -8,8 +8,14 @@
 // HELP-NOT: key-instructions
 
 // KEY-INSTRUCTIONS: "-gkey-instructions"
-// KEY-INSTRUCTIONS: "-mllvm" "-dwarf-use-key-instructions"
 
 // NO-KEY-INSTRUCTIONS-NOT: key-instructions
 
-//// TODO: Add smoke test once some functionality has been added.
+// RUN %clang %s | FileCheck %s --check-prefix=SMOKETEST-OFF
+void f() {}
+// SMOKETEST-OFF-NOT: keyInstructions
+// SMOKETEST-OFF-NOT: atomGroup
+
+// RUN %clang %s -gkey-instructions | FileCheck %s --check-prefix=SMOKETEST-ON
+// SMOKETEST-ON: keyInstructions: true
+// SMOKETEST-ON: atomGroup: 1

>From 632932ad1b3eee6d8057fca2b322e46dd2be751c Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams <orlando.hyams at sony.com>
Date: Mon, 30 Jun 2025 08:41:15 +0100
Subject: [PATCH 2/3] fix run lines

---
 clang/test/DebugInfo/KeyInstructions/flag.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/test/DebugInfo/KeyInstructions/flag.cpp b/clang/test/DebugInfo/KeyInstructions/flag.cpp
index 8ce140a2ca031..623ee3e1a8002 100644
--- a/clang/test/DebugInfo/KeyInstructions/flag.cpp
+++ b/clang/test/DebugInfo/KeyInstructions/flag.cpp
@@ -4,18 +4,18 @@
 // RUN: %clang -### -target x86_64 -c -gdwarf %s 2>&1 | FileCheck %s --check-prefixes=NO-KEY-INSTRUCTIONS
 
 //// Help hidden.
-// RUN %clang --help | FileCheck %s --check-prefix=HELP
+// RUN: %clang --help | FileCheck %s --check-prefix=HELP
 // HELP-NOT: key-instructions
 
 // KEY-INSTRUCTIONS: "-gkey-instructions"
 
 // NO-KEY-INSTRUCTIONS-NOT: key-instructions
 
-// RUN %clang %s | FileCheck %s --check-prefix=SMOKETEST-OFF
+// RUN: %clang_cc1 %s -triple x86_64-linux-gnu -debug-info-kind=line-tables-only -emit-llvm -o - | FileCheck %s --check-prefix=SMOKETEST-OFF
 void f() {}
-// SMOKETEST-OFF-NOT: keyInstructions
+// SMOKETEST-OFF-NOT: keyInstructions:
 // SMOKETEST-OFF-NOT: atomGroup
 
-// RUN %clang %s -gkey-instructions | FileCheck %s --check-prefix=SMOKETEST-ON
+// RUN: %clang_cc1 %s -triple x86_64-linux-gnu -gkey-instructions -debug-info-kind=line-tables-only -emit-llvm -o - | FileCheck %s --check-prefix=SMOKETEST-ON
 // SMOKETEST-ON: keyInstructions: true
 // SMOKETEST-ON: atomGroup: 1

>From e6a423eab19a0d0c594c220aab03663bdd0d12aa Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams <orlando.hyams at sony.com>
Date: Mon, 30 Jun 2025 08:43:12 +0100
Subject: [PATCH 3/3] improve test readability

---
 clang/test/DebugInfo/KeyInstructions/flag.cpp | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/clang/test/DebugInfo/KeyInstructions/flag.cpp b/clang/test/DebugInfo/KeyInstructions/flag.cpp
index 623ee3e1a8002..813f7e908011c 100644
--- a/clang/test/DebugInfo/KeyInstructions/flag.cpp
+++ b/clang/test/DebugInfo/KeyInstructions/flag.cpp
@@ -3,16 +3,16 @@
 //// Default: Off.
 // RUN: %clang -### -target x86_64 -c -gdwarf %s 2>&1 | FileCheck %s --check-prefixes=NO-KEY-INSTRUCTIONS
 
-//// Help hidden.
-// RUN: %clang --help | FileCheck %s --check-prefix=HELP
-// HELP-NOT: key-instructions
-
 // KEY-INSTRUCTIONS: "-gkey-instructions"
-
 // NO-KEY-INSTRUCTIONS-NOT: key-instructions
 
-// RUN: %clang_cc1 %s -triple x86_64-linux-gnu -debug-info-kind=line-tables-only -emit-llvm -o - | FileCheck %s --check-prefix=SMOKETEST-OFF
+//// Help hidden: flag should not be visible.
+// RUN: %clang --help | FileCheck %s --check-prefix=HELP
+// HELP-NOT: key-instructions
+
+// Smoke test: check for Key Instructions keywords in the IR.
 void f() {}
+// RUN: %clang_cc1 %s -triple x86_64-linux-gnu -debug-info-kind=line-tables-only -emit-llvm -o - | FileCheck %s --check-prefix=SMOKETEST-OFF
 // SMOKETEST-OFF-NOT: keyInstructions:
 // SMOKETEST-OFF-NOT: atomGroup
 



More information about the cfe-commits mailing list