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 @@ -61,7 +61,6 @@ /// Stack of Module description, enough to print the module after a given /// pass. SmallVector ModuleDescStack; - bool StoreModuleDesc = false; }; class OptNoneInstrumentation { 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 @@ -709,7 +709,6 @@ } void PrintIRInstrumentation::pushModuleDesc(StringRef PassID, Any IR) { - assert(StoreModuleDesc); const Module *M = unwrapModule(IR); ModuleDescStack.emplace_back(M, getIRName(IR), PassID); } @@ -730,7 +729,7 @@ // Note: here we rely on a fact that we do not change modules while // traversing the pipeline, so the latest captured module is good // for all print operations that has not happen yet. - if (StoreModuleDesc && shouldPrintAfterPass(PassID)) + if (shouldPrintAfterPass(PassID)) pushModuleDesc(PassID, IR); if (!shouldPrintBeforePass(PassID)) @@ -751,25 +750,22 @@ if (!shouldPrintAfterPass(PassID)) return; - if (StoreModuleDesc) { - const Module *M; - std::string IRName; - StringRef StoredPassID; - std::tie(M, IRName, StoredPassID) = popModuleDesc(PassID); - assert(StoredPassID == PassID && "mismatched PassID"); - } + const Module *M; + std::string IRName; + StringRef StoredPassID; + std::tie(M, IRName, StoredPassID) = popModuleDesc(PassID); + assert(StoredPassID == PassID && "mismatched PassID"); if (!shouldPrintIR(IR)) return; - dbgs() << "*** IR Dump After " << PassID << " on " << getIRName(IR) - << " ***\n"; + dbgs() << "*** IR Dump After " << PassID << " on " << IRName << " ***\n"; unwrapAndPrint(dbgs(), IR); } void PrintIRInstrumentation::printAfterPassInvalidated(StringRef PassID) { StringRef PassName = PIC->getPassNameForClassName(PassID); - if (!StoreModuleDesc || !shouldPrintAfterPass(PassName)) + if (!shouldPrintAfterPass(PassName)) return; if (isIgnored(PassID)) @@ -813,8 +809,7 @@ // BeforePass callback is not just for printing, it also saves a Module // for later use in AfterPassInvalidated. - StoreModuleDesc = forcePrintModuleIR() && shouldPrintAfterSomePass(); - if (shouldPrintBeforeSomePass() || StoreModuleDesc) + if (shouldPrintBeforeSomePass() || shouldPrintAfterSomePass()) PIC.registerBeforeNonSkippedPassCallback( [this](StringRef P, Any IR) { this->printBeforePass(P, IR); }); diff --git a/llvm/test/Other/loop-deletion-printer.ll b/llvm/test/Other/loop-deletion-printer.ll --- a/llvm/test/Other/loop-deletion-printer.ll +++ b/llvm/test/Other/loop-deletion-printer.ll @@ -6,13 +6,11 @@ ; RUN: opt < %s -disable-output \ ; RUN: -passes=loop-deletion,loop-instsimplify -print-after-all 2>&1 | FileCheck %s -check-prefix=DELETED ; RUN: opt < %s -disable-output \ -; RUN: -passes=loop-deletion,loop-instsimplify -print-after-all -print-module-scope 2>&1 | FileCheck %s -check-prefix=DELETED-BUT-PRINTED +; RUN: -passes=loop-deletion,loop-instsimplify -print-after-all -print-module-scope 2>&1 | FileCheck %s -check-prefix=DELETED ; ; SIMPLIFY: IR Dump {{.*}} LoopInstSimplifyPass +; DELETED: IR Dump {{.*}}LoopDeletionPass {{.*}}(invalidated) ; DELETED-NOT: IR Dump {{.*}}LoopInstSimplifyPass -; DELETED-NOT: IR Dump {{.*}}LoopDeletionPass -; DELETED-BUT-PRINTED: IR Dump {{.*}}LoopDeletionPass {{.*}}(invalidated) -; DELETED-BUT-PRINTED-NOT: IR Dump {{.*}}LoopInstSimplifyPass define void @deleteme() { entry: diff --git a/llvm/test/Other/scc-deleted-printer.ll b/llvm/test/Other/scc-deleted-printer.ll --- a/llvm/test/Other/scc-deleted-printer.ll +++ b/llvm/test/Other/scc-deleted-printer.ll @@ -1,17 +1,12 @@ ; RUN: opt < %s 2>&1 -disable-output \ -; RUN: -passes=inline -print-before-all -print-after-all | FileCheck %s -check-prefix=INL +; RUN: -passes=inline -print-before-all -print-after-all | FileCheck %s ; RUN: opt < %s 2>&1 -disable-output \ -; RUN: -passes=inline -print-before-all -print-after-all -print-module-scope | FileCheck %s -check-prefix=INL-MOD +; RUN: -passes=inline -print-before-all -print-after-all -print-module-scope | FileCheck %s -; INL: IR Dump Before InlinerPass on (tester, foo) -; INL-NOT: IR Dump After {{InlinerPass}} -; INL: IR Dump Before InlinerPass on (tester) -; INL: IR Dump After InlinerPass on (tester) - -; INL-MOD: IR Dump Before InlinerPass on (tester, foo) -; INL-MOD: IR Dump After InlinerPass on (tester, foo) (invalidated) -; INL-MOD: IR Dump Before InlinerPass on (tester) -; INL-MOD: IR Dump After InlinerPass on (tester) +; CHECK: IR Dump Before InlinerPass on (tester, foo) +; CHECK: IR Dump After InlinerPass on (tester, foo) (invalidated) +; CHECK: IR Dump Before InlinerPass on (tester) +; CHECK: IR Dump After InlinerPass on (tester) define void @tester() noinline {