[llvm] [CodeGen] Port mir-strip-debug to new pass manager (PR #190738)

via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 15 00:09:02 PDT 2026


https://github.com/juanvazquez updated https://github.com/llvm/llvm-project/pull/190738

>From 8d95a48d368f66c6acf0f147c9235b74d36ec0fe Mon Sep 17 00:00:00 2001
From: Juan Vazquez <juvazq at google.com>
Date: Sun, 22 Mar 2026 18:04:23 +0100
Subject: [PATCH 1/5] [CodeGen] Port mir-strip-debug to new pass manager

---
 llvm/include/llvm/CodeGen/MachineStripDebug.h |  19 +++
 llvm/include/llvm/CodeGen/Passes.h            |   3 +-
 .../llvm/Passes/MachinePassRegistry.def       |   2 +-
 llvm/lib/CodeGen/MachineStripDebug.cpp        | 125 +++++++++++-------
 llvm/lib/CodeGen/TargetPassConfig.cpp         |   2 +-
 llvm/lib/Passes/PassBuilder.cpp               |   1 +
 llvm/lib/Passes/PassRegistry.def              |   1 +
 7 files changed, 105 insertions(+), 48 deletions(-)
 create mode 100644 llvm/include/llvm/CodeGen/MachineStripDebug.h

diff --git a/llvm/include/llvm/CodeGen/MachineStripDebug.h b/llvm/include/llvm/CodeGen/MachineStripDebug.h
new file mode 100644
index 0000000000000..b6d9b32f2f589
--- /dev/null
+++ b/llvm/include/llvm/CodeGen/MachineStripDebug.h
@@ -0,0 +1,19 @@
+#ifndef LLVM_CODEGEN_MACHINESTRIPDEBUG_H
+#define LLVM_CODEGEN_MACHINESTRIPDEBUG_H
+
+#include "llvm/IR/Analysis.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IR/PassManager.h"
+#include "llvm/Support/Compiler.h"
+
+namespace llvm {
+
+class StripDebugMachineModulePass
+    : public PassInfoMixin<StripDebugMachineModulePass> {
+public:
+  LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
+};
+
+} // namespace llvm
+
+#endif
diff --git a/llvm/include/llvm/CodeGen/Passes.h b/llvm/include/llvm/CodeGen/Passes.h
index bd5844f715de5..cb1f413d1ad1b 100644
--- a/llvm/include/llvm/CodeGen/Passes.h
+++ b/llvm/include/llvm/CodeGen/Passes.h
@@ -600,7 +600,8 @@ LLVM_ABI ModulePass *createDebugifyMachineModulePass();
 /// If OnlyDebugified is true then it will only strip debug info if it was
 /// added by a Debugify pass. The module will be left unchanged if the debug
 /// info was generated by another source such as clang.
-LLVM_ABI ModulePass *createStripDebugMachineModulePass(bool OnlyDebugified);
+LLVM_ABI ModulePass *
+createStripDebugMachineModulePassLegacy(bool OnlyDebugified);
 
 /// Creates MIR Check Debug pass. \see MachineCheckDebugify.cpp
 LLVM_ABI ModulePass *createCheckDebugMachineModulePass();
diff --git a/llvm/include/llvm/Passes/MachinePassRegistry.def b/llvm/include/llvm/Passes/MachinePassRegistry.def
index 98fa48604e7a2..ec1209fc5dc18 100644
--- a/llvm/include/llvm/Passes/MachinePassRegistry.def
+++ b/llvm/include/llvm/Passes/MachinePassRegistry.def
@@ -27,6 +27,7 @@ MODULE_ANALYSIS("pass-instrumentation", PassInstrumentationAnalysis(PIC))
 MODULE_PASS("global-merge", GlobalMergePass(TM, GlobalMergeOptions()))
 MODULE_PASS("jmc-instrumenter", JMCInstrumenterPass())
 MODULE_PASS("lower-emutls", LowerEmuTLSPass())
+MODULE_PASS("mir-strip-debug", StripDebugMachineModulePass())
 MODULE_PASS("pre-isel-intrinsic-lowering", PreISelIntrinsicLoweringPass())
 MODULE_PASS("print<regusage>", PhysicalRegisterUsageInfoPrinterPass(errs()))
 MODULE_PASS("shadow-stack-gc-lowering", ShadowStackGCLoweringPass())
@@ -261,7 +262,6 @@ DUMMY_MACHINE_MODULE_PASS("static-data-annotator", StaticDataAnnotator)
 DUMMY_MACHINE_MODULE_PASS("pseudo-probe-inserter", PseudoProbeInserterPass)
 DUMMY_MACHINE_MODULE_PASS("mir-debugify", DebugifyMachineModule)
 DUMMY_MACHINE_MODULE_PASS("mir-check-debugify", CheckDebugMachineModulePass)
-DUMMY_MACHINE_MODULE_PASS("mir-strip-debug", StripDebugMachineModulePass)
 #undef DUMMY_MACHINE_MODULE_PASS
 
 #ifndef DUMMY_MACHINE_FUNCTION_PASS
diff --git a/llvm/lib/CodeGen/MachineStripDebug.cpp b/llvm/lib/CodeGen/MachineStripDebug.cpp
index d54fe023a4a7e..2aaac60ed37e6 100644
--- a/llvm/lib/CodeGen/MachineStripDebug.cpp
+++ b/llvm/lib/CodeGen/MachineStripDebug.cpp
@@ -10,10 +10,15 @@
 /// tests can be debugified without affecting the output MIR.
 //===----------------------------------------------------------------------===//
 
+#include "llvm/CodeGen/MachineStripDebug.h"
 #include "llvm/CodeGen/MachineBasicBlock.h"
 #include "llvm/CodeGen/MachineFunction.h"
+#include "llvm/CodeGen/MachineFunctionAnalysis.h"
 #include "llvm/CodeGen/MachineModuleInfo.h"
 #include "llvm/CodeGen/Passes.h"
+#include "llvm/IR/Analysis.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IR/PassManager.h"
 #include "llvm/InitializePasses.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Transforms/Utils/Debugify.h"
@@ -22,61 +27,76 @@
 
 using namespace llvm;
 
-namespace {
-cl::opt<bool>
-    OnlyDebugifiedDefault("mir-strip-debugify-only",
-                          cl::desc("Should mir-strip-debug only strip debug "
-                                   "info from debugified modules by default"),
-                          cl::init(true));
+static inline MachineFunction *getMachineFunction(Function &F,
+                                                  MachineModuleInfo &MMI) {
+  return MMI.getMachineFunction(F);
+}
 
-struct StripDebugMachineModule : public ModulePass {
-  bool runOnModule(Module &M) override {
-    if (OnlyDebugified) {
-      NamedMDNode *DebugifyMD = M.getNamedMetadata("llvm.debugify");
-      if (!DebugifyMD) {
-        LLVM_DEBUG(dbgs() << "Not stripping debug info"
-                             " (debugify metadata not found)?\n");
-        return false;
-      }
-    }
+static inline MachineFunction *
+getMachineFunction(Function &F, FunctionAnalysisManager &FAM) {
+  return &FAM.getResult<MachineFunctionAnalysis>(F).getMF();
+}
 
-    MachineModuleInfo &MMI =
-        getAnalysis<MachineModuleInfoWrapperPass>().getMMI();
+template <typename ContextT>
+static bool stripDebugMachineModuleImpl(Module &M, ContextT &Context,
+                                        bool OnlyDebugified) {
+  if (OnlyDebugified) {
+    NamedMDNode *DebugifyMD = M.getNamedMetadata("llvm.debugify");
+    if (!DebugifyMD) {
+      LLVM_DEBUG(dbgs() << "Not stripping debug info"
+                           " (debugify metadata not found)?\n");
+      return false;
+    }
+  }
 
-    bool Changed = false;
-    for (Function &F : M.functions()) {
-      MachineFunction *MaybeMF = MMI.getMachineFunction(F);
-      if (!MaybeMF)
-        continue;
-      MachineFunction &MF = *MaybeMF;
-      for (MachineBasicBlock &MBB : MF) {
-        for (MachineInstr &MI : llvm::make_early_inc_range(MBB.instrs())) {
-          if (MI.isDebugInstr()) {
-            // FIXME: We should remove all of them. However, AArch64 emits an
-            //        invalid `DBG_VALUE $lr` with only one operand instead of
-            //        the usual three and has a test that depends on it's
-            //        preservation. Preserve it for now.
-            if (MI.getNumOperands() > 1) {
-              LLVM_DEBUG(dbgs() << "Removing debug instruction " << MI);
-              MBB.erase_instr(&MI);
-              Changed |= true;
-              continue;
-            }
-          }
-          if (MI.getDebugLoc()) {
-            LLVM_DEBUG(dbgs() << "Removing location " << MI);
-            MI.setDebugLoc(DebugLoc());
+  bool Changed = false;
+  for (Function &F : M.functions()) {
+    MachineFunction *MaybeMF = getMachineFunction(F, Context);
+    if (!MaybeMF)
+      continue;
+    MachineFunction &MF = *MaybeMF;
+    for (MachineBasicBlock &MBB : MF) {
+      for (MachineInstr &MI : llvm::make_early_inc_range(MBB.instrs())) {
+        if (MI.isDebugInstr()) {
+          // FIXME: We should remove all of them. However, AArch64 emits an
+          //        invalid `DBG_VALUE $lr` with only one operand instead of
+          //        the usual three and has a test that depends on it's
+          //        preservation. Preserve it for now.
+          if (MI.getNumOperands() > 1) {
+            LLVM_DEBUG(dbgs() << "Removing debug instruction " << MI);
+            MBB.erase_instr(&MI);
             Changed |= true;
             continue;
           }
-          LLVM_DEBUG(dbgs() << "Keeping " << MI);
         }
+        if (MI.getDebugLoc()) {
+          LLVM_DEBUG(dbgs() << "Removing location " << MI);
+          MI.setDebugLoc(DebugLoc());
+          Changed |= true;
+          continue;
+        }
+        LLVM_DEBUG(dbgs() << "Keeping " << MI);
       }
     }
+  }
+
+  Changed |= stripDebugifyMetadata(M);
 
-    Changed |= stripDebugifyMetadata(M);
+  return Changed;
+}
+
+namespace {
+cl::opt<bool>
+    OnlyDebugifiedDefault("mir-strip-debugify-only",
+                          cl::desc("Should mir-strip-debug only strip debug "
+                                   "info from debugified modules by default"),
+                          cl::init(true));
 
-    return Changed;
+struct StripDebugMachineModule : public ModulePass {
+  bool runOnModule(Module &M) override {
+    MachineModuleInfo &MMI =
+        getAnalysis<MachineModuleInfoWrapperPass>().getMMI();
+    return stripDebugMachineModuleImpl(M, MMI, OnlyDebugified);
   }
 
   StripDebugMachineModule() : StripDebugMachineModule(OnlyDebugifiedDefault) {}
@@ -103,6 +123,21 @@ INITIALIZE_PASS_BEGIN(StripDebugMachineModule, DEBUG_TYPE,
 INITIALIZE_PASS_END(StripDebugMachineModule, DEBUG_TYPE,
                     "Machine Strip Debug Module", false, false)
 
-ModulePass *llvm::createStripDebugMachineModulePass(bool OnlyDebugified) {
+ModulePass *llvm::createStripDebugMachineModulePassLegacy(bool OnlyDebugified) {
   return new StripDebugMachineModule(OnlyDebugified);
 }
+
+PreservedAnalyses StripDebugMachineModulePass::run(Module &M,
+                                                   ModuleAnalysisManager &AM) {
+  FunctionAnalysisManager &FAM =
+      AM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();
+  bool Changed = stripDebugMachineModuleImpl(M, FAM, OnlyDebugifiedDefault);
+  if (!Changed) {
+    return PreservedAnalyses::all();
+  }
+
+  PreservedAnalyses PA;
+  PA.preserveSet<AllAnalysesOn<Module>>();
+  PA.preserveSet<CFGAnalyses>();
+  return PA;
+}
diff --git a/llvm/lib/CodeGen/TargetPassConfig.cpp b/llvm/lib/CodeGen/TargetPassConfig.cpp
index 4aa99340ef1d4..2a01760cd7922 100644
--- a/llvm/lib/CodeGen/TargetPassConfig.cpp
+++ b/llvm/lib/CodeGen/TargetPassConfig.cpp
@@ -810,7 +810,7 @@ void TargetPassConfig::addDebugifyPass() {
 }
 
 void TargetPassConfig::addStripDebugPass() {
-  PM->add(createStripDebugMachineModulePass(/*OnlyDebugified=*/true));
+  PM->add(createStripDebugMachineModulePassLegacy(/*OnlyDebugified=*/true));
 }
 
 void TargetPassConfig::addCheckDebugPass() {
diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index 55a4e99e7402e..cf044d9c6ed79 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -134,6 +134,7 @@
 #include "llvm/CodeGen/MachineRegisterInfo.h"
 #include "llvm/CodeGen/MachineScheduler.h"
 #include "llvm/CodeGen/MachineSink.h"
+#include "llvm/CodeGen/MachineStripDebug.h"
 #include "llvm/CodeGen/MachineTraceMetrics.h"
 #include "llvm/CodeGen/MachineUniformityAnalysis.h"
 #include "llvm/CodeGen/MachineVerifier.h"
diff --git a/llvm/lib/Passes/PassRegistry.def b/llvm/lib/Passes/PassRegistry.def
index c92d93d7ae396..7fbbe6e612a4a 100644
--- a/llvm/lib/Passes/PassRegistry.def
+++ b/llvm/lib/Passes/PassRegistry.def
@@ -119,6 +119,7 @@ MODULE_PASS("memprof-remove-attributes", MemProfRemoveInfo())
 MODULE_PASS("memprof-module", ModuleMemProfilerPass())
 MODULE_PASS("mergefunc", MergeFunctionsPass())
 MODULE_PASS("metarenamer", MetaRenamerPass())
+MODULE_PASS("mir-strip-debug", StripDebugMachineModulePass())
 MODULE_PASS("module-inline", ModuleInlinerPass())
 MODULE_PASS("name-anon-globals", NameAnonGlobalPass())
 MODULE_PASS("no-op-module", NoOpModulePass())

>From a7d04b3c1a4283034cc77189db991e11bc5c8ef8 Mon Sep 17 00:00:00 2001
From: Juan Vazquez <juvazq at google.com>
Date: Tue, 7 Apr 2026 17:39:18 +0200
Subject: [PATCH 2/5] Fix review feedback

---
 llvm/include/llvm/CodeGen/Passes.h     |  2 +-
 llvm/lib/CodeGen/MachineStripDebug.cpp | 32 +++++++++++---------------
 llvm/lib/CodeGen/TargetPassConfig.cpp  |  2 +-
 3 files changed, 15 insertions(+), 21 deletions(-)

diff --git a/llvm/include/llvm/CodeGen/Passes.h b/llvm/include/llvm/CodeGen/Passes.h
index cb1f413d1ad1b..44b702e3676b9 100644
--- a/llvm/include/llvm/CodeGen/Passes.h
+++ b/llvm/include/llvm/CodeGen/Passes.h
@@ -601,7 +601,7 @@ LLVM_ABI ModulePass *createDebugifyMachineModulePass();
 /// added by a Debugify pass. The module will be left unchanged if the debug
 /// info was generated by another source such as clang.
 LLVM_ABI ModulePass *
-createStripDebugMachineModulePassLegacy(bool OnlyDebugified);
+createStripDebugMachineModuleLegacyPass(bool OnlyDebugified);
 
 /// Creates MIR Check Debug pass. \see MachineCheckDebugify.cpp
 LLVM_ABI ModulePass *createCheckDebugMachineModulePass();
diff --git a/llvm/lib/CodeGen/MachineStripDebug.cpp b/llvm/lib/CodeGen/MachineStripDebug.cpp
index 2aaac60ed37e6..071ae5d26339d 100644
--- a/llvm/lib/CodeGen/MachineStripDebug.cpp
+++ b/llvm/lib/CodeGen/MachineStripDebug.cpp
@@ -27,19 +27,11 @@
 
 using namespace llvm;
 
-static inline MachineFunction *getMachineFunction(Function &F,
-                                                  MachineModuleInfo &MMI) {
-  return MMI.getMachineFunction(F);
-}
-
-static inline MachineFunction *
-getMachineFunction(Function &F, FunctionAnalysisManager &FAM) {
-  return &FAM.getResult<MachineFunctionAnalysis>(F).getMF();
-}
+namespace {
 
-template <typename ContextT>
-static bool stripDebugMachineModuleImpl(Module &M, ContextT &Context,
-                                        bool OnlyDebugified) {
+bool stripDebugMachineModuleImpl(
+    Module &M, llvm::function_ref<MachineFunction *(Function &)> GetMF,
+    bool OnlyDebugified) {
   if (OnlyDebugified) {
     NamedMDNode *DebugifyMD = M.getNamedMetadata("llvm.debugify");
     if (!DebugifyMD) {
@@ -51,7 +43,7 @@ static bool stripDebugMachineModuleImpl(Module &M, ContextT &Context,
 
   bool Changed = false;
   for (Function &F : M.functions()) {
-    MachineFunction *MaybeMF = getMachineFunction(F, Context);
+    MachineFunction *MaybeMF = GetMF(F);
     if (!MaybeMF)
       continue;
     MachineFunction &MF = *MaybeMF;
@@ -85,7 +77,6 @@ static bool stripDebugMachineModuleImpl(Module &M, ContextT &Context,
   return Changed;
 }
 
-namespace {
 cl::opt<bool>
     OnlyDebugifiedDefault("mir-strip-debugify-only",
                           cl::desc("Should mir-strip-debug only strip debug "
@@ -96,7 +87,8 @@ struct StripDebugMachineModule : public ModulePass {
   bool runOnModule(Module &M) override {
     MachineModuleInfo &MMI =
         getAnalysis<MachineModuleInfoWrapperPass>().getMMI();
-    return stripDebugMachineModuleImpl(M, MMI, OnlyDebugified);
+    auto GetMF = [&MMI](Function &F) { return MMI.getMachineFunction(F); };
+    return stripDebugMachineModuleImpl(M, GetMF, OnlyDebugified);
   }
 
   StripDebugMachineModule() : StripDebugMachineModule(OnlyDebugifiedDefault) {}
@@ -123,7 +115,7 @@ INITIALIZE_PASS_BEGIN(StripDebugMachineModule, DEBUG_TYPE,
 INITIALIZE_PASS_END(StripDebugMachineModule, DEBUG_TYPE,
                     "Machine Strip Debug Module", false, false)
 
-ModulePass *llvm::createStripDebugMachineModulePassLegacy(bool OnlyDebugified) {
+ModulePass *llvm::createStripDebugMachineModuleLegacyPass(bool OnlyDebugified) {
   return new StripDebugMachineModule(OnlyDebugified);
 }
 
@@ -131,10 +123,12 @@ PreservedAnalyses StripDebugMachineModulePass::run(Module &M,
                                                    ModuleAnalysisManager &AM) {
   FunctionAnalysisManager &FAM =
       AM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();
-  bool Changed = stripDebugMachineModuleImpl(M, FAM, OnlyDebugifiedDefault);
-  if (!Changed) {
+  auto GetMF = [&FAM](Function &F) {
+    return &FAM.getResult<MachineFunctionAnalysis>(F).getMF();
+  };
+  bool Changed = stripDebugMachineModuleImpl(M, GetMF, OnlyDebugifiedDefault);
+  if (!Changed)
     return PreservedAnalyses::all();
-  }
 
   PreservedAnalyses PA;
   PA.preserveSet<AllAnalysesOn<Module>>();
diff --git a/llvm/lib/CodeGen/TargetPassConfig.cpp b/llvm/lib/CodeGen/TargetPassConfig.cpp
index 2a01760cd7922..8e5b0f0d4221e 100644
--- a/llvm/lib/CodeGen/TargetPassConfig.cpp
+++ b/llvm/lib/CodeGen/TargetPassConfig.cpp
@@ -810,7 +810,7 @@ void TargetPassConfig::addDebugifyPass() {
 }
 
 void TargetPassConfig::addStripDebugPass() {
-  PM->add(createStripDebugMachineModulePassLegacy(/*OnlyDebugified=*/true));
+  PM->add(createStripDebugMachineModuleLegacyPass(/*OnlyDebugified=*/true));
 }
 
 void TargetPassConfig::addCheckDebugPass() {

>From 4c1c08d7b17dd620e158603a5a040aba32095619 Mon Sep 17 00:00:00 2001
From: Juan Vazquez <juvazq at google.com>
Date: Wed, 8 Apr 2026 09:42:22 +0200
Subject: [PATCH 3/5] Address review feedback

---
 llvm/lib/CodeGen/MachineStripDebug.cpp | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/llvm/lib/CodeGen/MachineStripDebug.cpp b/llvm/lib/CodeGen/MachineStripDebug.cpp
index 071ae5d26339d..866f02c9fc7bd 100644
--- a/llvm/lib/CodeGen/MachineStripDebug.cpp
+++ b/llvm/lib/CodeGen/MachineStripDebug.cpp
@@ -30,8 +30,8 @@ using namespace llvm;
 namespace {
 
 bool stripDebugMachineModuleImpl(
-    Module &M, llvm::function_ref<MachineFunction *(Function &)> GetMF,
-    bool OnlyDebugified) {
+    Module &M, bool OnlyDebugified,
+    llvm::function_ref<MachineFunction *(Function &)> GetMF) {
   if (OnlyDebugified) {
     NamedMDNode *DebugifyMD = M.getNamedMetadata("llvm.debugify");
     if (!DebugifyMD) {
@@ -87,8 +87,10 @@ struct StripDebugMachineModule : public ModulePass {
   bool runOnModule(Module &M) override {
     MachineModuleInfo &MMI =
         getAnalysis<MachineModuleInfoWrapperPass>().getMMI();
-    auto GetMF = [&MMI](Function &F) { return MMI.getMachineFunction(F); };
-    return stripDebugMachineModuleImpl(M, GetMF, OnlyDebugified);
+    return stripDebugMachineModuleImpl(
+        M, OnlyDebugified, [&MMI](Function &F) -> MachineFunction * {
+          return MMI.getMachineFunction(F);
+        });
   }
 
   StripDebugMachineModule() : StripDebugMachineModule(OnlyDebugifiedDefault) {}
@@ -123,15 +125,16 @@ PreservedAnalyses StripDebugMachineModulePass::run(Module &M,
                                                    ModuleAnalysisManager &AM) {
   FunctionAnalysisManager &FAM =
       AM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();
-  auto GetMF = [&FAM](Function &F) {
-    return &FAM.getResult<MachineFunctionAnalysis>(F).getMF();
-  };
-  bool Changed = stripDebugMachineModuleImpl(M, GetMF, OnlyDebugifiedDefault);
+  bool Changed = stripDebugMachineModuleImpl(
+      M, OnlyDebugifiedDefault, [&FAM](Function &F) -> MachineFunction * {
+        return &FAM.getResult<MachineFunctionAnalysis>(F).getMF();
+      });
   if (!Changed)
     return PreservedAnalyses::all();
 
   PreservedAnalyses PA;
-  PA.preserveSet<AllAnalysesOn<Module>>();
+  PA.preserve<MachineModuleAnalysis>();
+  PA.preserve<FunctionAnalysisManagerModuleProxy>();
   PA.preserveSet<CFGAnalyses>();
   return PA;
 }

>From 888a86330a58a26102e98d430e8af51be643edcb Mon Sep 17 00:00:00 2001
From: Juan Vazquez <juvazq at google.com>
Date: Thu, 9 Apr 2026 09:03:52 +0200
Subject: [PATCH 4/5] Address feedback

---
 llvm/include/llvm/CodeGen/MachineStripDebug.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/llvm/include/llvm/CodeGen/MachineStripDebug.h b/llvm/include/llvm/CodeGen/MachineStripDebug.h
index b6d9b32f2f589..bece8df946d60 100644
--- a/llvm/include/llvm/CodeGen/MachineStripDebug.h
+++ b/llvm/include/llvm/CodeGen/MachineStripDebug.h
@@ -1,3 +1,11 @@
+//===-- MachineStripDebug.h -------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
 #ifndef LLVM_CODEGEN_MACHINESTRIPDEBUG_H
 #define LLVM_CODEGEN_MACHINESTRIPDEBUG_H
 

>From be91b554974dd09d1e93d66edb709f3de4fc4cfc Mon Sep 17 00:00:00 2001
From: Juan Vazquez <juvazq at google.com>
Date: Wed, 15 Apr 2026 08:51:12 +0200
Subject: [PATCH 5/5] Address feedback for file header

---
 llvm/include/llvm/CodeGen/MachineStripDebug.h | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/llvm/include/llvm/CodeGen/MachineStripDebug.h b/llvm/include/llvm/CodeGen/MachineStripDebug.h
index bece8df946d60..0f5ccb1338ac3 100644
--- a/llvm/include/llvm/CodeGen/MachineStripDebug.h
+++ b/llvm/include/llvm/CodeGen/MachineStripDebug.h
@@ -1,10 +1,15 @@
-//===-- MachineStripDebug.h -------------------------------------*- C++ -*-===//
+//===- MachineStripDebug.h - Strip debug info -----------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
+//
+// This removes debug info from everything. It can be used to ensure tests can
+// be debugified without affecting the output MIR.
+//
+//===----------------------------------------------------------------------===//
 
 #ifndef LLVM_CODEGEN_MACHINESTRIPDEBUG_H
 #define LLVM_CODEGEN_MACHINESTRIPDEBUG_H
@@ -24,4 +29,4 @@ class StripDebugMachineModulePass
 
 } // namespace llvm
 
-#endif
+#endif // LLVM_CODEGEN_MACHINESTRIPDEBUG_H



More information about the llvm-commits mailing list