diff --git a/llvm/include/llvm/IR/PassManager.h b/llvm/include/llvm/IR/PassManager.h --- a/llvm/include/llvm/IR/PassManager.h +++ b/llvm/include/llvm/IR/PassManager.h @@ -503,9 +503,6 @@ for (unsigned Idx = 0, Size = Passes.size(); Idx != Size; ++Idx) { auto *P = Passes[Idx].get(); - if (DebugLogging) - dbgs() << "Running pass: " << P->name() << " on " << IR.getName() - << "\n"; // Check the PassInstrumentation's BeforePass callbacks before running the // pass, skip its execution completely if asked to (callback returns @@ -513,6 +510,10 @@ if (!PI.runBeforePass(*P, IR)) continue; + if (DebugLogging) + dbgs() << "Running pass: " << P->name() << " on " << IR.getName() + << "\n"; + PreservedAnalyses PassPA; { TimeTraceScope TimeScope(P->name(), IR.getName()); diff --git a/llvm/lib/Analysis/CGSCCPassManager.cpp b/llvm/lib/Analysis/CGSCCPassManager.cpp --- a/llvm/lib/Analysis/CGSCCPassManager.cpp +++ b/llvm/lib/Analysis/CGSCCPassManager.cpp @@ -73,14 +73,14 @@ AM.getCachedResult(*C)->getManager(); for (auto &Pass : Passes) { - if (DebugLogging) - dbgs() << "Running pass: " << Pass->name() << " on " << *C << "\n"; - // Check the PassInstrumentation's BeforePass callbacks before running the // pass, skip its execution completely if asked to (callback returns false). if (!PI.runBeforePass(*Pass, *C)) continue; + if (DebugLogging) + dbgs() << "Running pass: " << Pass->name() << " on " << *C << "\n"; + PreservedAnalyses PassPA; { TimeTraceScope TimeScope(Pass->name()); diff --git a/llvm/lib/Transforms/Scalar/LoopPassManager.cpp b/llvm/lib/Transforms/Scalar/LoopPassManager.cpp --- a/llvm/lib/Transforms/Scalar/LoopPassManager.cpp +++ b/llvm/lib/Transforms/Scalar/LoopPassManager.cpp @@ -34,14 +34,14 @@ // instrumenting callbacks for the passes later. PassInstrumentation PI = AM.getResult(L, AR); for (auto &Pass : Passes) { - if (DebugLogging) - dbgs() << "Running pass: " << Pass->name() << " on " << L; - // Check the PassInstrumentation's BeforePass callbacks before running the // pass, skip its execution completely if asked to (callback returns false). if (!PI.runBeforePass(*Pass, L)) continue; + if (DebugLogging) + dbgs() << "Running pass: " << Pass->name() << " on " << L; + PreservedAnalyses PassPA; { TimeTraceScope TimeScope(Pass->name(), L.getName());