[clang] 73777b4 - [Debugify] Optimize debugify original mode

Djordje Todorovic via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 22 04:14:27 PDT 2022


Author: Djordje Todorovic
Date: 2022-03-22T12:14:00+01:00
New Revision: 73777b4c35a390617cce0f6b4516e98fe5a88df1

URL: https://github.com/llvm/llvm-project/commit/73777b4c35a390617cce0f6b4516e98fe5a88df1
DIFF: https://github.com/llvm/llvm-project/commit/73777b4c35a390617cce0f6b4516e98fe5a88df1.diff

LOG: [Debugify] Optimize debugify original mode

Before we start addressing the issue with having
a lot of false positives when using debugify in
the original mode, we have made a few patches that
should speed up the execution of the testing
utility Passes.

For example, when testing a large project
(let's say LLVM project itself), we can face
a lot of potential DI issues. Usually, we use
-verify-each-debuginfo-preserve (that is very
similar to -debugify-each) -- it collects
DI metadata before each Pass, and after the Pass
it checks if the Pass preserved the DI metadata.
However, we can speed up this process, since we
don't need to collect DI metadata before each
Pass -- we could use the DI metadata that are
collected after the previous Pass from
the pipeline as an input for the next Pass.

This patch speeds up the utility for ~2x.

Differential Revision: https://reviews.llvm.org/D115622

Added: 
    

Modified: 
    clang/lib/CodeGen/BackendUtil.cpp
    llvm/include/llvm/Transforms/Utils/Debugify.h
    llvm/lib/Transforms/Utils/Debugify.cpp
    llvm/tools/opt/opt.cpp
    llvm/unittests/Transforms/Utils/DebugifyTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index 716a565ee7871..eaf34eedcb2bb 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -1003,10 +1003,10 @@ void EmitAssemblyHelper::EmitAssemblyWithLegacyPassManager(
     TheModule->setDataLayout(TM->createDataLayout());
 
   DebugifyCustomPassManager PerModulePasses;
-  DebugInfoPerPassMap DIPreservationMap;
+  DebugInfoPerPass DebugInfoBeforePass;
   if (CodeGenOpts.EnableDIPreservationVerify) {
     PerModulePasses.setDebugifyMode(DebugifyMode::OriginalDebugInfo);
-    PerModulePasses.setDIPreservationMap(DIPreservationMap);
+    PerModulePasses.setDebugInfoBeforePass(DebugInfoBeforePass);
 
     if (!CodeGenOpts.DIBugsReportFilePath.empty())
       PerModulePasses.setOrigDIVerifyBugsReportFilePath(

diff  --git a/llvm/include/llvm/Transforms/Utils/Debugify.h b/llvm/include/llvm/Transforms/Utils/Debugify.h
index 892e354cd9edb..405bbb8e0be8a 100644
--- a/llvm/include/llvm/Transforms/Utils/Debugify.h
+++ b/llvm/include/llvm/Transforms/Utils/Debugify.h
@@ -23,7 +23,8 @@
 #include "llvm/IR/ValueHandle.h"
 #include "llvm/Pass.h"
 
-using DebugFnMap = llvm::MapVector<llvm::StringRef, const llvm::DISubprogram *>;
+using DebugFnMap =
+    llvm::MapVector<const llvm::Function *, const llvm::DISubprogram *>;
 using DebugInstMap = llvm::MapVector<const llvm::Instruction *, bool>;
 using DebugVarMap = llvm::MapVector<const llvm::DILocalVariable *, unsigned>;
 using WeakInstValueMap =
@@ -42,9 +43,6 @@ struct DebugInfoPerPass {
   DebugVarMap DIVariables;
 };
 
-/// Map pass names to a per-pass DebugInfoPerPass instance.
-using DebugInfoPerPassMap = llvm::MapVector<llvm::StringRef, DebugInfoPerPass>;
-
 namespace llvm {
 class DIBuilder;
 
@@ -69,24 +67,24 @@ bool stripDebugifyMetadata(Module &M);
 ///
 /// \param M The module to collect debug information from.
 /// \param Functions A range of functions to collect debug information from.
-/// \param DIPreservationMap A map to collect the DI metadata.
+/// \param DebugInfoBeforePass DI metadata before a pass.
 /// \param Banner A prefix string to add to debug/error messages.
 /// \param NameOfWrappedPass A name of a pass to add to debug/error messages.
 bool collectDebugInfoMetadata(Module &M,
                               iterator_range<Module::iterator> Functions,
-                              DebugInfoPerPassMap &DIPreservationMap,
+                              DebugInfoPerPass &DebugInfoBeforePass,
                               StringRef Banner, StringRef NameOfWrappedPass);
 
 /// Check original debug information after a pass.
 ///
 /// \param M The module to collect debug information from.
 /// \param Functions A range of functions to collect debug information from.
-/// \param DIPreservationMap A map used to check collected the DI metadata.
+/// \param DebugInfoBeforePass DI metadata before a pass.
 /// \param Banner A prefix string to add to debug/error messages.
 /// \param NameOfWrappedPass A name of a pass to add to debug/error messages.
 bool checkDebugInfoMetadata(Module &M,
                             iterator_range<Module::iterator> Functions,
-                            DebugInfoPerPassMap &DIPreservationMap,
+                            DebugInfoPerPass &DebugInfoBeforePass,
                             StringRef Banner, StringRef NameOfWrappedPass,
                             StringRef OrigDIVerifyBugsReportFilePath);
 } // namespace llvm
@@ -97,11 +95,11 @@ enum class DebugifyMode { NoDebugify, SyntheticDebugInfo, OriginalDebugInfo };
 llvm::ModulePass *createDebugifyModulePass(
     enum DebugifyMode Mode = DebugifyMode::SyntheticDebugInfo,
     llvm::StringRef NameOfWrappedPass = "",
-    DebugInfoPerPassMap *DIPreservationMap = nullptr);
+    DebugInfoPerPass *DebugInfoBeforePass = nullptr);
 llvm::FunctionPass *createDebugifyFunctionPass(
     enum DebugifyMode Mode = DebugifyMode::SyntheticDebugInfo,
     llvm::StringRef NameOfWrappedPass = "",
-    DebugInfoPerPassMap *DIPreservationMap = nullptr);
+    DebugInfoPerPass *DebugInfoBeforePass = nullptr);
 
 struct NewPMDebugifyPass : public llvm::PassInfoMixin<NewPMDebugifyPass> {
   llvm::PreservedAnalyses run(llvm::Module &M, llvm::ModuleAnalysisManager &AM);
@@ -140,14 +138,14 @@ llvm::ModulePass *createCheckDebugifyModulePass(
     bool Strip = false, llvm::StringRef NameOfWrappedPass = "",
     DebugifyStatsMap *StatsMap = nullptr,
     enum DebugifyMode Mode = DebugifyMode::SyntheticDebugInfo,
-    DebugInfoPerPassMap *DIPreservationMap = nullptr,
+    DebugInfoPerPass *DebugInfoBeforePass = nullptr,
     llvm::StringRef OrigDIVerifyBugsReportFilePath = "");
 
 llvm::FunctionPass *createCheckDebugifyFunctionPass(
     bool Strip = false, llvm::StringRef NameOfWrappedPass = "",
     DebugifyStatsMap *StatsMap = nullptr,
     enum DebugifyMode Mode = DebugifyMode::SyntheticDebugInfo,
-    DebugInfoPerPassMap *DIPreservationMap = nullptr,
+    DebugInfoPerPass *DebugInfoBeforePass = nullptr,
     llvm::StringRef OrigDIVerifyBugsReportFilePath = "");
 
 struct NewPMCheckDebugifyPass
@@ -171,7 +169,7 @@ struct DebugifyEachInstrumentation {
 class DebugifyCustomPassManager : public legacy::PassManager {
   StringRef OrigDIVerifyBugsReportFilePath;
   DebugifyStatsMap *DIStatsMap = nullptr;
-  DebugInfoPerPassMap *DIPreservationMap = nullptr;
+  DebugInfoPerPass *DebugInfoBeforePass = nullptr;
   enum DebugifyMode Mode = DebugifyMode::NoDebugify;
 
 public:
@@ -197,17 +195,17 @@ class DebugifyCustomPassManager : public legacy::PassManager {
     // TODO: Implement Debugify for LoopPass.
     switch (Kind) {
     case PT_Function:
-      super::add(createDebugifyFunctionPass(Mode, Name, DIPreservationMap));
+      super::add(createDebugifyFunctionPass(Mode, Name, DebugInfoBeforePass));
       super::add(P);
       super::add(createCheckDebugifyFunctionPass(
-          isSyntheticDebugInfo(), Name, DIStatsMap, Mode, DIPreservationMap,
+          isSyntheticDebugInfo(), Name, DIStatsMap, Mode, DebugInfoBeforePass,
           OrigDIVerifyBugsReportFilePath));
       break;
     case PT_Module:
-      super::add(createDebugifyModulePass(Mode, Name, DIPreservationMap));
+      super::add(createDebugifyModulePass(Mode, Name, DebugInfoBeforePass));
       super::add(P);
       super::add(createCheckDebugifyModulePass(
-          isSyntheticDebugInfo(), Name, DIStatsMap, Mode, DIPreservationMap,
+          isSyntheticDebugInfo(), Name, DIStatsMap, Mode, DebugInfoBeforePass,
           OrigDIVerifyBugsReportFilePath));
       break;
     default:
@@ -219,8 +217,8 @@ class DebugifyCustomPassManager : public legacy::PassManager {
   // Used within DebugifyMode::SyntheticDebugInfo mode.
   void setDIStatsMap(DebugifyStatsMap &StatMap) { DIStatsMap = &StatMap; }
   // Used within DebugifyMode::OriginalDebugInfo mode.
-  void setDIPreservationMap(DebugInfoPerPassMap &PerPassMap) {
-    DIPreservationMap = &PerPassMap;
+  void setDebugInfoBeforePass(DebugInfoPerPass &PerPassDI) {
+    DebugInfoBeforePass = &PerPassDI;
   }
   void setOrigDIVerifyBugsReportFilePath(StringRef BugsReportFilePath) {
     OrigDIVerifyBugsReportFilePath = BugsReportFilePath;
@@ -239,7 +237,7 @@ class DebugifyCustomPassManager : public legacy::PassManager {
   }
 
   const DebugifyStatsMap &getDebugifyStatsMap() const { return *DIStatsMap; }
-  DebugInfoPerPassMap &getDebugInfoPerPassMap() { return *DIPreservationMap; }
+  DebugInfoPerPass &getDebugInfoPerPass() { return *DebugInfoBeforePass; }
 };
 } // namespace llvm
 

diff  --git a/llvm/lib/Transforms/Utils/Debugify.cpp b/llvm/lib/Transforms/Utils/Debugify.cpp
index 589622d695780..84fe65671d069 100644
--- a/llvm/lib/Transforms/Utils/Debugify.cpp
+++ b/llvm/lib/Transforms/Utils/Debugify.cpp
@@ -210,15 +210,15 @@ bool llvm::applyDebugifyMetadata(
 static bool
 applyDebugify(Function &F,
               enum DebugifyMode Mode = DebugifyMode::SyntheticDebugInfo,
-              DebugInfoPerPassMap *DIPreservationMap = nullptr,
+              DebugInfoPerPass *DebugInfoBeforePass = nullptr,
               StringRef NameOfWrappedPass = "") {
   Module &M = *F.getParent();
   auto FuncIt = F.getIterator();
   if (Mode == DebugifyMode::SyntheticDebugInfo)
     return applyDebugifyMetadata(M, make_range(FuncIt, std::next(FuncIt)),
                                  "FunctionDebugify: ", /*ApplyToMF*/ nullptr);
-  assert(DIPreservationMap);
-  return collectDebugInfoMetadata(M, M.functions(), *DIPreservationMap,
+  assert(DebugInfoBeforePass);
+  return collectDebugInfoMetadata(M, M.functions(), *DebugInfoBeforePass,
                                   "FunctionDebugify (original debuginfo)",
                                   NameOfWrappedPass);
 }
@@ -226,12 +226,12 @@ applyDebugify(Function &F,
 static bool
 applyDebugify(Module &M,
               enum DebugifyMode Mode = DebugifyMode::SyntheticDebugInfo,
-              DebugInfoPerPassMap *DIPreservationMap = nullptr,
+              DebugInfoPerPass *DebugInfoBeforePass = nullptr,
               StringRef NameOfWrappedPass = "") {
   if (Mode == DebugifyMode::SyntheticDebugInfo)
     return applyDebugifyMetadata(M, M.functions(),
                                  "ModuleDebugify: ", /*ApplyToMF*/ nullptr);
-  return collectDebugInfoMetadata(M, M.functions(), *DIPreservationMap,
+  return collectDebugInfoMetadata(M, M.functions(), *DebugInfoBeforePass,
                                   "ModuleDebugify (original debuginfo)",
                                   NameOfWrappedPass);
 }
@@ -283,14 +283,11 @@ bool llvm::stripDebugifyMetadata(Module &M) {
 
 bool llvm::collectDebugInfoMetadata(Module &M,
                                     iterator_range<Module::iterator> Functions,
-                                    DebugInfoPerPassMap &DIPreservationMap,
+                                    DebugInfoPerPass &DebugInfoBeforePass,
                                     StringRef Banner,
                                     StringRef NameOfWrappedPass) {
   LLVM_DEBUG(dbgs() << Banner << ": (before) " << NameOfWrappedPass << '\n');
 
-  // Clear the map with the debug info before every single pass.
-  DIPreservationMap.clear();
-
   if (!M.getNamedMetadata("llvm.dbg.cu")) {
     dbg() << Banner << ": Skipping module without debug info\n";
     return false;
@@ -298,17 +295,21 @@ bool llvm::collectDebugInfoMetadata(Module &M,
 
   // Visit each instruction.
   for (Function &F : Functions) {
+    // Use DI collected after previous Pass (when -debugify-each is used).
+    if (DebugInfoBeforePass.DIFunctions.count(&F))
+      continue;
+
     if (isFunctionSkipped(F))
       continue;
 
     // Collect the DISubprogram.
     auto *SP = F.getSubprogram();
-    DIPreservationMap[NameOfWrappedPass].DIFunctions.insert({F.getName(), SP});
+    DebugInfoBeforePass.DIFunctions.insert({&F, SP});
     if (SP) {
       LLVM_DEBUG(dbgs() << "  Collecting subprogram: " << *SP << '\n');
       for (const DINode *DN : SP->getRetainedNodes()) {
         if (const auto *DV = dyn_cast<DILocalVariable>(DN)) {
-          DIPreservationMap[NameOfWrappedPass].DIVariables[DV] = 0;
+          DebugInfoBeforePass.DIVariables[DV] = 0;
         }
       }
     }
@@ -332,7 +333,7 @@ bool llvm::collectDebugInfoMetadata(Module &M,
             continue;
 
           auto *Var = DVI->getVariable();
-          DIPreservationMap[NameOfWrappedPass].DIVariables[Var]++;
+          DebugInfoBeforePass.DIVariables[Var]++;
           continue;
         }
 
@@ -341,11 +342,11 @@ bool llvm::collectDebugInfoMetadata(Module &M,
           continue;
 
         LLVM_DEBUG(dbgs() << "  Collecting info for inst: " << I << '\n');
-        DIPreservationMap[NameOfWrappedPass].InstToDelete.insert({&I, &I});
+        DebugInfoBeforePass.InstToDelete.insert({&I, &I});
 
         const DILocation *Loc = I.getDebugLoc().get();
         bool HasLoc = Loc != nullptr;
-        DIPreservationMap[NameOfWrappedPass].DILocations.insert({&I, HasLoc});
+        DebugInfoBeforePass.DILocations.insert({&I, HasLoc});
       }
     }
   }
@@ -367,12 +368,12 @@ static bool checkFunctions(const DebugFnMap &DIFunctionsBefore,
     if (SPIt == DIFunctionsBefore.end()) {
       if (ShouldWriteIntoJSON)
         Bugs.push_back(llvm::json::Object({{"metadata", "DISubprogram"},
-                                           {"name", F.first},
+                                           {"name", F.first->getName()},
                                            {"action", "not-generate"}}));
       else
         dbg() << "ERROR: " << NameOfWrappedPass
-              << " did not generate DISubprogram for " << F.first << " from "
-              << FileNameFromCU << '\n';
+              << " did not generate DISubprogram for " << F.first->getName()
+              << " from " << FileNameFromCU << '\n';
       Preserved = false;
     } else {
       auto SP = SPIt->second;
@@ -382,11 +383,11 @@ static bool checkFunctions(const DebugFnMap &DIFunctionsBefore,
       // a debug info bug.
       if (ShouldWriteIntoJSON)
         Bugs.push_back(llvm::json::Object({{"metadata", "DISubprogram"},
-                                           {"name", F.first},
+                                           {"name", F.first->getName()},
                                            {"action", "drop"}}));
       else
         dbg() << "ERROR: " << NameOfWrappedPass << " dropped DISubprogram of "
-              << F.first << " from " << FileNameFromCU << '\n';
+              << F.first->getName() << " from " << FileNameFromCU << '\n';
       Preserved = false;
     }
   }
@@ -515,7 +516,7 @@ static void writeJSON(StringRef OrigDIVerifyBugsReportFilePath,
 
 bool llvm::checkDebugInfoMetadata(Module &M,
                                   iterator_range<Module::iterator> Functions,
-                                  DebugInfoPerPassMap &DIPreservationMap,
+                                  DebugInfoPerPass &DebugInfoBeforePass,
                                   StringRef Banner, StringRef NameOfWrappedPass,
                                   StringRef OrigDIVerifyBugsReportFilePath) {
   LLVM_DEBUG(dbgs() << Banner << ": (after) " << NameOfWrappedPass << '\n');
@@ -526,7 +527,7 @@ bool llvm::checkDebugInfoMetadata(Module &M,
   }
 
   // Map the debug info holding DIs after a pass.
-  DebugInfoPerPassMap DIPreservationAfter;
+  DebugInfoPerPass DebugInfoAfterPass;
 
   // Visit each instruction.
   for (Function &F : Functions) {
@@ -536,14 +537,13 @@ bool llvm::checkDebugInfoMetadata(Module &M,
     // TODO: Collect metadata other than DISubprograms.
     // Collect the DISubprogram.
     auto *SP = F.getSubprogram();
-    DIPreservationAfter[NameOfWrappedPass].DIFunctions.insert(
-        {F.getName(), SP});
+    DebugInfoAfterPass.DIFunctions.insert({&F, SP});
 
     if (SP) {
       LLVM_DEBUG(dbgs() << "  Collecting subprogram: " << *SP << '\n');
       for (const DINode *DN : SP->getRetainedNodes()) {
         if (const auto *DV = dyn_cast<DILocalVariable>(DN)) {
-          DIPreservationAfter[NameOfWrappedPass].DIVariables[DV] = 0;
+          DebugInfoAfterPass.DIVariables[DV] = 0;
         }
       }
     }
@@ -567,7 +567,7 @@ bool llvm::checkDebugInfoMetadata(Module &M,
             continue;
 
           auto *Var = DVI->getVariable();
-          DIPreservationAfter[NameOfWrappedPass].DIVariables[Var]++;
+          DebugInfoAfterPass.DIVariables[Var]++;
           continue;
         }
 
@@ -580,7 +580,7 @@ bool llvm::checkDebugInfoMetadata(Module &M,
         const DILocation *Loc = I.getDebugLoc().get();
         bool HasLoc = Loc != nullptr;
 
-        DIPreservationAfter[NameOfWrappedPass].DILocations.insert({&I, HasLoc});
+        DebugInfoAfterPass.DILocations.insert({&I, HasLoc});
       }
     }
   }
@@ -590,16 +590,16 @@ bool llvm::checkDebugInfoMetadata(Module &M,
       (cast<DICompileUnit>(M.getNamedMetadata("llvm.dbg.cu")->getOperand(0)))
           ->getFilename();
 
-  auto DIFunctionsBefore = DIPreservationMap[NameOfWrappedPass].DIFunctions;
-  auto DIFunctionsAfter = DIPreservationAfter[NameOfWrappedPass].DIFunctions;
+  auto DIFunctionsBefore = DebugInfoBeforePass.DIFunctions;
+  auto DIFunctionsAfter = DebugInfoAfterPass.DIFunctions;
 
-  auto DILocsBefore = DIPreservationMap[NameOfWrappedPass].DILocations;
-  auto DILocsAfter = DIPreservationAfter[NameOfWrappedPass].DILocations;
+  auto DILocsBefore = DebugInfoBeforePass.DILocations;
+  auto DILocsAfter = DebugInfoAfterPass.DILocations;
 
-  auto InstToDelete = DIPreservationMap[NameOfWrappedPass].InstToDelete;
+  auto InstToDelete = DebugInfoBeforePass.InstToDelete;
 
-  auto DIVarsBefore = DIPreservationMap[NameOfWrappedPass].DIVariables;
-  auto DIVarsAfter = DIPreservationAfter[NameOfWrappedPass].DIVariables;
+  auto DIVarsBefore = DebugInfoBeforePass.DIVariables;
+  auto DIVarsAfter = DebugInfoAfterPass.DIVariables;
 
   bool ShouldWriteIntoJSON = !OrigDIVerifyBugsReportFilePath.empty();
   llvm::json::Array Bugs;
@@ -626,6 +626,11 @@ bool llvm::checkDebugInfoMetadata(Module &M,
   else
     dbg() << ResultBanner << ": FAIL\n";
 
+  // In the case of the `debugify-each`, no need to go over all the instructions
+  // again in the collectDebugInfoMetadata(), since as an input we can use
+  // the debugging information from the previous pass.
+  DebugInfoBeforePass = DebugInfoAfterPass;
+
   LLVM_DEBUG(dbgs() << "\n\n");
   return Result;
 }
@@ -770,14 +775,14 @@ bool checkDebugifyMetadata(Module &M,
 /// legacy module pass manager.
 struct DebugifyModulePass : public ModulePass {
   bool runOnModule(Module &M) override {
-    return applyDebugify(M, Mode, DIPreservationMap, NameOfWrappedPass);
+    return applyDebugify(M, Mode, DebugInfoBeforePass, NameOfWrappedPass);
   }
 
   DebugifyModulePass(enum DebugifyMode Mode = DebugifyMode::SyntheticDebugInfo,
                      StringRef NameOfWrappedPass = "",
-                     DebugInfoPerPassMap *DIPreservationMap = nullptr)
+                     DebugInfoPerPass *DebugInfoBeforePass = nullptr)
       : ModulePass(ID), NameOfWrappedPass(NameOfWrappedPass),
-        DIPreservationMap(DIPreservationMap), Mode(Mode) {}
+        DebugInfoBeforePass(DebugInfoBeforePass), Mode(Mode) {}
 
   void getAnalysisUsage(AnalysisUsage &AU) const override {
     AU.setPreservesAll();
@@ -787,7 +792,7 @@ struct DebugifyModulePass : public ModulePass {
 
 private:
   StringRef NameOfWrappedPass;
-  DebugInfoPerPassMap *DIPreservationMap;
+  DebugInfoPerPass *DebugInfoBeforePass;
   enum DebugifyMode Mode;
 };
 
@@ -795,15 +800,15 @@ struct DebugifyModulePass : public ModulePass {
 /// single function, used with the legacy module pass manager.
 struct DebugifyFunctionPass : public FunctionPass {
   bool runOnFunction(Function &F) override {
-    return applyDebugify(F, Mode, DIPreservationMap, NameOfWrappedPass);
+    return applyDebugify(F, Mode, DebugInfoBeforePass, NameOfWrappedPass);
   }
 
   DebugifyFunctionPass(
       enum DebugifyMode Mode = DebugifyMode::SyntheticDebugInfo,
       StringRef NameOfWrappedPass = "",
-      DebugInfoPerPassMap *DIPreservationMap = nullptr)
+      DebugInfoPerPass *DebugInfoBeforePass = nullptr)
       : FunctionPass(ID), NameOfWrappedPass(NameOfWrappedPass),
-        DIPreservationMap(DIPreservationMap), Mode(Mode) {}
+        DebugInfoBeforePass(DebugInfoBeforePass), Mode(Mode) {}
 
   void getAnalysisUsage(AnalysisUsage &AU) const override {
     AU.setPreservesAll();
@@ -813,7 +818,7 @@ struct DebugifyFunctionPass : public FunctionPass {
 
 private:
   StringRef NameOfWrappedPass;
-  DebugInfoPerPassMap *DIPreservationMap;
+  DebugInfoPerPass *DebugInfoBeforePass;
   enum DebugifyMode Mode;
 };
 
@@ -825,7 +830,7 @@ struct CheckDebugifyModulePass : public ModulePass {
       return checkDebugifyMetadata(M, M.functions(), NameOfWrappedPass,
                                    "CheckModuleDebugify", Strip, StatsMap);
     return checkDebugInfoMetadata(
-        M, M.functions(), *DIPreservationMap,
+        M, M.functions(), *DebugInfoBeforePass,
         "CheckModuleDebugify (original debuginfo)", NameOfWrappedPass,
         OrigDIVerifyBugsReportFilePath);
   }
@@ -834,11 +839,11 @@ struct CheckDebugifyModulePass : public ModulePass {
       bool Strip = false, StringRef NameOfWrappedPass = "",
       DebugifyStatsMap *StatsMap = nullptr,
       enum DebugifyMode Mode = DebugifyMode::SyntheticDebugInfo,
-      DebugInfoPerPassMap *DIPreservationMap = nullptr,
+      DebugInfoPerPass *DebugInfoBeforePass = nullptr,
       StringRef OrigDIVerifyBugsReportFilePath = "")
       : ModulePass(ID), NameOfWrappedPass(NameOfWrappedPass),
         OrigDIVerifyBugsReportFilePath(OrigDIVerifyBugsReportFilePath),
-        StatsMap(StatsMap), DIPreservationMap(DIPreservationMap), Mode(Mode),
+        StatsMap(StatsMap), DebugInfoBeforePass(DebugInfoBeforePass), Mode(Mode),
         Strip(Strip) {}
 
   void getAnalysisUsage(AnalysisUsage &AU) const override {
@@ -851,7 +856,7 @@ struct CheckDebugifyModulePass : public ModulePass {
   StringRef NameOfWrappedPass;
   StringRef OrigDIVerifyBugsReportFilePath;
   DebugifyStatsMap *StatsMap;
-  DebugInfoPerPassMap *DIPreservationMap;
+  DebugInfoPerPass *DebugInfoBeforePass;
   enum DebugifyMode Mode;
   bool Strip;
 };
@@ -867,7 +872,7 @@ struct CheckDebugifyFunctionPass : public FunctionPass {
                                    NameOfWrappedPass, "CheckFunctionDebugify",
                                    Strip, StatsMap);
     return checkDebugInfoMetadata(
-        M, make_range(FuncIt, std::next(FuncIt)), *DIPreservationMap,
+        M, make_range(FuncIt, std::next(FuncIt)), *DebugInfoBeforePass,
         "CheckFunctionDebugify (original debuginfo)", NameOfWrappedPass,
         OrigDIVerifyBugsReportFilePath);
   }
@@ -876,11 +881,11 @@ struct CheckDebugifyFunctionPass : public FunctionPass {
       bool Strip = false, StringRef NameOfWrappedPass = "",
       DebugifyStatsMap *StatsMap = nullptr,
       enum DebugifyMode Mode = DebugifyMode::SyntheticDebugInfo,
-      DebugInfoPerPassMap *DIPreservationMap = nullptr,
+      DebugInfoPerPass *DebugInfoBeforePass = nullptr,
       StringRef OrigDIVerifyBugsReportFilePath = "")
       : FunctionPass(ID), NameOfWrappedPass(NameOfWrappedPass),
         OrigDIVerifyBugsReportFilePath(OrigDIVerifyBugsReportFilePath),
-        StatsMap(StatsMap), DIPreservationMap(DIPreservationMap), Mode(Mode),
+        StatsMap(StatsMap), DebugInfoBeforePass(DebugInfoBeforePass), Mode(Mode),
         Strip(Strip) {}
 
   void getAnalysisUsage(AnalysisUsage &AU) const override {
@@ -893,7 +898,7 @@ struct CheckDebugifyFunctionPass : public FunctionPass {
   StringRef NameOfWrappedPass;
   StringRef OrigDIVerifyBugsReportFilePath;
   DebugifyStatsMap *StatsMap;
-  DebugInfoPerPassMap *DIPreservationMap;
+  DebugInfoPerPass *DebugInfoBeforePass;
   enum DebugifyMode Mode;
   bool Strip;
 };
@@ -923,21 +928,21 @@ void llvm::exportDebugifyStats(StringRef Path, const DebugifyStatsMap &Map) {
 
 ModulePass *createDebugifyModulePass(enum DebugifyMode Mode,
                                      llvm::StringRef NameOfWrappedPass,
-                                     DebugInfoPerPassMap *DIPreservationMap) {
+                                     DebugInfoPerPass *DebugInfoBeforePass) {
   if (Mode == DebugifyMode::SyntheticDebugInfo)
     return new DebugifyModulePass();
   assert(Mode == DebugifyMode::OriginalDebugInfo && "Must be original mode");
-  return new DebugifyModulePass(Mode, NameOfWrappedPass, DIPreservationMap);
+  return new DebugifyModulePass(Mode, NameOfWrappedPass, DebugInfoBeforePass);
 }
 
 FunctionPass *
 createDebugifyFunctionPass(enum DebugifyMode Mode,
                            llvm::StringRef NameOfWrappedPass,
-                           DebugInfoPerPassMap *DIPreservationMap) {
+                           DebugInfoPerPass *DebugInfoBeforePass) {
   if (Mode == DebugifyMode::SyntheticDebugInfo)
     return new DebugifyFunctionPass();
   assert(Mode == DebugifyMode::OriginalDebugInfo && "Must be original mode");
-  return new DebugifyFunctionPass(Mode, NameOfWrappedPass, DIPreservationMap);
+  return new DebugifyFunctionPass(Mode, NameOfWrappedPass, DebugInfoBeforePass);
 }
 
 PreservedAnalyses NewPMDebugifyPass::run(Module &M, ModuleAnalysisManager &) {
@@ -948,25 +953,25 @@ PreservedAnalyses NewPMDebugifyPass::run(Module &M, ModuleAnalysisManager &) {
 
 ModulePass *createCheckDebugifyModulePass(
     bool Strip, StringRef NameOfWrappedPass, DebugifyStatsMap *StatsMap,
-    enum DebugifyMode Mode, DebugInfoPerPassMap *DIPreservationMap,
+    enum DebugifyMode Mode, DebugInfoPerPass *DebugInfoBeforePass,
     StringRef OrigDIVerifyBugsReportFilePath) {
   if (Mode == DebugifyMode::SyntheticDebugInfo)
     return new CheckDebugifyModulePass(Strip, NameOfWrappedPass, StatsMap);
   assert(Mode == DebugifyMode::OriginalDebugInfo && "Must be original mode");
   return new CheckDebugifyModulePass(false, NameOfWrappedPass, nullptr, Mode,
-                                     DIPreservationMap,
+                                     DebugInfoBeforePass,
                                      OrigDIVerifyBugsReportFilePath);
 }
 
 FunctionPass *createCheckDebugifyFunctionPass(
     bool Strip, StringRef NameOfWrappedPass, DebugifyStatsMap *StatsMap,
-    enum DebugifyMode Mode, DebugInfoPerPassMap *DIPreservationMap,
+    enum DebugifyMode Mode, DebugInfoPerPass *DebugInfoBeforePass,
     StringRef OrigDIVerifyBugsReportFilePath) {
   if (Mode == DebugifyMode::SyntheticDebugInfo)
     return new CheckDebugifyFunctionPass(Strip, NameOfWrappedPass, StatsMap);
   assert(Mode == DebugifyMode::OriginalDebugInfo && "Must be original mode");
   return new CheckDebugifyFunctionPass(false, NameOfWrappedPass, nullptr, Mode,
-                                       DIPreservationMap,
+                                       DebugInfoBeforePass,
                                        OrigDIVerifyBugsReportFilePath);
 }
 

diff  --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp
index 5d047280ddb55..f707eb0f0b4a4 100644
--- a/llvm/tools/opt/opt.cpp
+++ b/llvm/tools/opt/opt.cpp
@@ -858,13 +858,13 @@ int main(int argc, char **argv) {
   // the (-check)-debugify passes.
   DebugifyCustomPassManager Passes;
   DebugifyStatsMap DIStatsMap;
-  DebugInfoPerPassMap DIPreservationMap;
+  DebugInfoPerPass DebugInfoBeforePass;
   if (DebugifyEach) {
     Passes.setDebugifyMode(DebugifyMode::SyntheticDebugInfo);
     Passes.setDIStatsMap(DIStatsMap);
   } else if (VerifyEachDebugInfoPreserve) {
     Passes.setDebugifyMode(DebugifyMode::OriginalDebugInfo);
-    Passes.setDIPreservationMap(DIPreservationMap);
+    Passes.setDebugInfoBeforePass(DebugInfoBeforePass);
     if (!VerifyDIPreserveExport.empty())
       Passes.setOrigDIVerifyBugsReportFilePath(VerifyDIPreserveExport);
   }
@@ -884,10 +884,10 @@ int main(int argc, char **argv) {
       Passes.setDIStatsMap(DIStatsMap);
       Passes.add(createDebugifyModulePass());
     } else if (VerifyDebugInfoPreserve) {
-      Passes.setDIPreservationMap(DIPreservationMap);
+      Passes.setDebugInfoBeforePass(DebugInfoBeforePass);
       Passes.add(createDebugifyModulePass(
           DebugifyMode::OriginalDebugInfo, "",
-          &(Passes.getDebugInfoPerPassMap())));
+          &(Passes.getDebugInfoPerPass())));
     }
   }
 
@@ -1026,7 +1026,7 @@ int main(int argc, char **argv) {
         Passes.setOrigDIVerifyBugsReportFilePath(VerifyDIPreserveExport);
       Passes.add(createCheckDebugifyModulePass(
           false, "", nullptr, DebugifyMode::OriginalDebugInfo,
-          &(Passes.getDebugInfoPerPassMap()), VerifyDIPreserveExport));
+          &(Passes.getDebugInfoPerPass()), VerifyDIPreserveExport));
     }
   }
 

diff  --git a/llvm/unittests/Transforms/Utils/DebugifyTest.cpp b/llvm/unittests/Transforms/Utils/DebugifyTest.cpp
index 33ff72c9d9e8c..089830967e642 100644
--- a/llvm/unittests/Transforms/Utils/DebugifyTest.cpp
+++ b/llvm/unittests/Transforms/Utils/DebugifyTest.cpp
@@ -121,15 +121,15 @@ TEST(DebugInfoDrop, DropOriginalDebugInfo) {
 
   DebugInfoDrop *P = new DebugInfoDrop();
 
-  DebugInfoPerPassMap DIPreservationMap;
+  DebugInfoPerPass DIBeforePass;
   DebugifyCustomPassManager Passes;
-  Passes.setDIPreservationMap(DIPreservationMap);
+  Passes.setDebugInfoBeforePass(DIBeforePass);
   Passes.add(createDebugifyModulePass(DebugifyMode::OriginalDebugInfo, "",
-                                      &(Passes.getDebugInfoPerPassMap())));
+                                      &(Passes.getDebugInfoPerPass())));
   Passes.add(P);
   Passes.add(createCheckDebugifyModulePass(false, "", nullptr,
                                            DebugifyMode::OriginalDebugInfo,
-                                           &(Passes.getDebugInfoPerPassMap())));
+                                           &(Passes.getDebugInfoPerPass())));
 
   testing::internal::CaptureStderr();
   Passes.run(*M);
@@ -172,15 +172,15 @@ TEST(DebugValueDrop, DropOriginalDebugValues) {
 
   DebugValueDrop *P = new DebugValueDrop();
 
-  DebugInfoPerPassMap DIPreservationMap;
+  DebugInfoPerPass DIBeforePass;
   DebugifyCustomPassManager Passes;
-  Passes.setDIPreservationMap(DIPreservationMap);
+  Passes.setDebugInfoBeforePass(DIBeforePass);
   Passes.add(createDebugifyModulePass(DebugifyMode::OriginalDebugInfo, "",
-                                      &(Passes.getDebugInfoPerPassMap())));
+                                      &(Passes.getDebugInfoPerPass())));
   Passes.add(P);
   Passes.add(createCheckDebugifyModulePass(false, "", nullptr,
                                            DebugifyMode::OriginalDebugInfo,
-                                           &(Passes.getDebugInfoPerPassMap())));
+                                           &(Passes.getDebugInfoPerPass())));
 
   testing::internal::CaptureStderr();
   Passes.run(*M);
@@ -225,15 +225,15 @@ TEST(DebugInfoDummyAnalysis, PreserveOriginalDebugInfo) {
 
   DebugInfoDummyAnalysis *P = new DebugInfoDummyAnalysis();
 
-  DebugInfoPerPassMap DIPreservationMap;
+  DebugInfoPerPass DIBeforePass;
   DebugifyCustomPassManager Passes;
-  Passes.setDIPreservationMap(DIPreservationMap);
+  Passes.setDebugInfoBeforePass(DIBeforePass);
   Passes.add(createDebugifyModulePass(DebugifyMode::OriginalDebugInfo, "",
-                                      &(Passes.getDebugInfoPerPassMap())));
+                                      &(Passes.getDebugInfoPerPass())));
   Passes.add(P);
   Passes.add(createCheckDebugifyModulePass(false, "", nullptr,
                                            DebugifyMode::OriginalDebugInfo,
-                                           &(Passes.getDebugInfoPerPassMap())));
+                                           &(Passes.getDebugInfoPerPass())));
 
   testing::internal::CaptureStderr();
   Passes.run(*M);


        


More information about the cfe-commits mailing list