[llvm] 3a3ee93 - [opt] Cleanups related to legacy PM deprecation

Bjorn Pettersson via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 13 01:12:39 PDT 2023


Author: Bjorn Pettersson
Date: 2023-04-13T10:12:00+02:00
New Revision: 3a3ee933f347af815f111c6f9352baf8cfd302fc

URL: https://github.com/llvm/llvm-project/commit/3a3ee933f347af815f111c6f9352baf8cfd302fc
DIFF: https://github.com/llvm/llvm-project/commit/3a3ee933f347af815f111c6f9352baf8cfd302fc.diff

LOG: [opt] Cleanups related to legacy PM deprecation

Remove dead code related to "FPasses". This was a leftover from
commit 7a5332b9b5584ce.

Do not mention -enable-new-pm in error messages. The option does
not exist any longer.

Remove the addPass helper. Only one use remained, so we can just
"inline" it manually to keep the code related to legacy PM a bit
less spread out.

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

Added: 
    

Modified: 
    llvm/tools/opt/opt.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp
index 76d396d82cb4..a9248efa189f 100644
--- a/llvm/tools/opt/opt.cpp
+++ b/llvm/tools/opt/opt.cpp
@@ -274,15 +274,6 @@ static cl::list<std::string>
     PassPlugins("load-pass-plugin",
                 cl::desc("Load passes from plugin library"));
 
-static inline void addPass(legacy::PassManagerBase &PM, Pass *P) {
-  // Add the pass to the pass manager...
-  PM.add(P);
-
-  // If we are verifying all of the intermediate steps, add the verifier...
-  if (VerifyEach)
-    PM.add(createVerifierPass());
-}
-
 //===----------------------------------------------------------------------===//
 // CodeGen-related helper functions.
 //
@@ -663,9 +654,8 @@ int main(int argc, char **argv) {
 
   if (UseNPM) {
     if (legacy::debugPassSpecified()) {
-      errs()
-          << "-debug-pass does not work with the new PM, either use "
-             "-debug-pass-manager, or use the legacy PM (-enable-new-pm=0)\n";
+      errs() << "-debug-pass does not work with the new PM, either use "
+                "-debug-pass-manager, or use the legacy PM\n";
       return 1;
     }
     auto NumOLevel = OptLevelO0 + OptLevelO1 + OptLevelO2 + OptLevelO3 +
@@ -773,8 +763,6 @@ int main(int argc, char **argv) {
     }
   }
 
-  std::unique_ptr<legacy::FunctionPassManager> FPasses;
-
   if (TM) {
     // FIXME: We should dyn_cast this when supported.
     auto &LTM = static_cast<LLVMTargetMachine &>(*TM);
@@ -785,21 +773,18 @@ int main(int argc, char **argv) {
   // Create a new optimization pass for each one specified on the command line
   for (unsigned i = 0; i < PassList.size(); ++i) {
     const PassInfo *PassInf = PassList[i];
-    Pass *P = nullptr;
-    if (PassInf->getNormalCtor())
-      P = PassInf->getNormalCtor()();
-    else
+    if (PassInf->getNormalCtor()) {
+      Pass *P = PassInf->getNormalCtor()();
+      if (P) {
+        // Add the pass to the pass manager.
+        Passes.add(P);
+        // If we are verifying all of the intermediate steps, add the verifier.
+        if (VerifyEach)
+          Passes.add(createVerifierPass());
+      }
+    } else
       errs() << argv[0] << ": cannot create pass: "
              << PassInf->getPassName() << "\n";
-    if (P)
-      addPass(Passes, P);
-  }
-
-  if (FPasses) {
-    FPasses->doInitialization();
-    for (Function &F : *M)
-      FPasses->run(F);
-    FPasses->doFinalization();
   }
 
   // Check that the module is well formed on completion of optimization


        


More information about the llvm-commits mailing list