diff --git a/llvm/include/llvm/IR/Verifier.h b/llvm/include/llvm/IR/Verifier.h --- a/llvm/include/llvm/IR/Verifier.h +++ b/llvm/include/llvm/IR/Verifier.h @@ -141,6 +141,8 @@ PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); + + static bool isRequired() { return true; } }; } // end namespace llvm diff --git a/llvm/include/llvm/Passes/StandardInstrumentations.h b/llvm/include/llvm/Passes/StandardInstrumentations.h --- a/llvm/include/llvm/Passes/StandardInstrumentations.h +++ b/llvm/include/llvm/Passes/StandardInstrumentations.h @@ -56,12 +56,11 @@ class OptNoneInstrumentation { public: - OptNoneInstrumentation(bool DebugLogging) : DebugLogging(DebugLogging) {} + OptNoneInstrumentation() {} void registerCallbacks(PassInstrumentationCallbacks &PIC); private: bool skip(StringRef PassID, Any IR); - bool DebugLogging; }; // Debug logging for transformation and analysis passes. @@ -83,8 +82,7 @@ OptNoneInstrumentation OptNone; public: - StandardInstrumentations(bool DebugLogging) - : PrintPass(DebugLogging), OptNone(DebugLogging) {} + StandardInstrumentations(bool DebugLogging) : PrintPass(DebugLogging) {} void registerCallbacks(PassInstrumentationCallbacks &PIC); diff --git a/llvm/lib/Passes/StandardInstrumentations.cpp b/llvm/lib/Passes/StandardInstrumentations.cpp --- a/llvm/lib/Passes/StandardInstrumentations.cpp +++ b/llvm/lib/Passes/StandardInstrumentations.cpp @@ -297,12 +297,7 @@ } else if (any_isa(IR)) { F = any_cast(IR)->getHeader()->getParent(); } - if (F && F->hasOptNone()) { - if (DebugLogging) - dbgs() << "Skipping pass: " << PassID << " (optnone)\n"; - return false; - } - return true; + return !(F && F->hasOptNone()); } void PrintPassInstrumentation::registerCallbacks( @@ -314,6 +309,14 @@ if (!DebugPMVerbose) SpecialPasses.emplace_back("PassAdaptor"); + PIC.registerBeforeSkippedPassCallback( + [SpecialPasses](StringRef PassID, Any IR) { + if (isSpecialPass(PassID, SpecialPasses)) + return; + + dbgs() << "Skipping pass: " << PassID << "\n"; + }); + PIC.registerBeforeNonSkippedPassCallback( [SpecialPasses](StringRef PassID, Any IR) { if (isSpecialPass(PassID, SpecialPasses)) diff --git a/llvm/test/Feature/optnone-opt.ll b/llvm/test/Feature/optnone-opt.ll --- a/llvm/test/Feature/optnone-opt.ll +++ b/llvm/test/Feature/optnone-opt.ll @@ -10,6 +10,7 @@ ; RUN: opt -enable-npm-optnone -O3 -S -debug-pass-manager -enable-new-pm %s 2>&1 | FileCheck %s --check-prefix=NPM-O1 --check-prefix=NPM-O2O3 ; RUN: opt -enable-npm-optnone -dce -gvn-hoist -loweratomic -S -debug-pass-manager -enable-new-pm %s 2>&1 | FileCheck %s --check-prefix=NPM-MORE ; RUN: opt -enable-npm-optnone -indvars -licm -loop-deletion -loop-idiom -loop-instsimplify -loop-reduce -loop-unroll -simple-loop-unswitch -S -debug-pass-manager -enable-new-pm %s 2>&1 | FileCheck %s --check-prefix=NPM-LOOP +; RUN: opt -enable-npm-optnone -passes='function(verify)' -S -debug-pass-manager -enable-new-pm %s 2>&1 | FileCheck %s --check-prefix=NPM-VERIFY ; REQUIRES: asserts @@ -90,3 +91,6 @@ ; NPM-LOOP-DAG: Skipping pass: LICMPass ; NPM-LOOP-DAG: Skipping pass: LoopIdiomRecognizePass ; NPM-LOOP-DAG: Skipping pass: LoopInstSimplifyPass + +; VerifierPass should not be skipped +; NPM-VERIFY-NOT: Skipping pass