diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp --- a/llvm/tools/opt/opt.cpp +++ b/llvm/tools/opt/opt.cpp @@ -274,15 +274,6 @@ 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 @@ 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 @@ } } - std::unique_ptr FPasses; - if (TM) { // FIXME: We should dyn_cast this when supported. auto <M = static_cast(*TM); @@ -785,21 +773,18 @@ // 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