From d409411ef195329a24cea00589e9853ab6a5ace8 Mon Sep 17 00:00:00 2001 From: Serge Pavlov Date: Fri, 13 Jan 2017 06:09:54 +0000 Subject: Track validity of pass results Running tests with expensive checks enabled exhibits some problems with verification of pass results. First, the pass verification may require results of analysis that are not available. For instance, verification of loop info requires results of dominator tree analysis. A pass may be marked as conserving loop info but does not need to be dependent on DominatorTreePass. When a pass manager tries to verify that loop info is valid, it needs dominator tree, but corresponding analysis may be already destroyed as no user of it remained. Another case is a pass that is skipped. For instance, entities with linkage available_externally do not need code generation and such passes are skipped for them. In this case result verification must also be skipped. To solve these problems this change introduces a special flag to the Pass structure to mark passes that have valid results. If this flag is reset, verifications dependent on the pass result are skipped. Differential Revision: https://reviews.llvm.org/D27190 llvm-svn: 291882 --- llvm/lib/Analysis/CallGraphSCCPass.cpp | 1 + llvm/lib/Analysis/LoopInfo.cpp | 6 ++++-- llvm/lib/Analysis/LoopPass.cpp | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) (limited to 'llvm/lib/Analysis') diff --git a/llvm/lib/Analysis/CallGraphSCCPass.cpp b/llvm/lib/Analysis/CallGraphSCCPass.cpp index 9cef7814415..290fd34cff5 100644 --- a/llvm/lib/Analysis/CallGraphSCCPass.cpp +++ b/llvm/lib/Analysis/CallGraphSCCPass.cpp @@ -414,6 +414,7 @@ bool CGPassManager::RunAllPassesOnSCC(CallGraphSCC &CurSCC, CallGraph &CG, initializeAnalysisImpl(P); // Actually run this pass on the current SCC. + P->setExecuted(true); Changed |= RunPassOnSCC(P, CurSCC, CG, CallGraphUpToDate, DevirtualizedCall); diff --git a/llvm/lib/Analysis/LoopInfo.cpp b/llvm/lib/Analysis/LoopInfo.cpp index f449ce94d57..1b5d6e5d1b7 100644 --- a/llvm/lib/Analysis/LoopInfo.cpp +++ b/llvm/lib/Analysis/LoopInfo.cpp @@ -722,8 +722,10 @@ void LoopInfoWrapperPass::verifyAnalysis() const { // checking by default, LoopPass has been taught to call verifyLoop manually // during loop pass sequences. if (VerifyLoopInfo) { - auto &DT = getAnalysis().getDomTree(); - LI.verify(DT); + if (auto *Analysis = getAnalysisIfAvailable()) { + auto &DT = Analysis->getDomTree(); + LI.verify(DT); + } } } diff --git a/llvm/lib/Analysis/LoopPass.cpp b/llvm/lib/Analysis/LoopPass.cpp index 3f4a0794215..d3e697e5c61 100644 --- a/llvm/lib/Analysis/LoopPass.cpp +++ b/llvm/lib/Analysis/LoopPass.cpp @@ -198,6 +198,7 @@ bool LPPassManager::runOnFunction(Function &F) { PassManagerPrettyStackEntry X(P, *CurrentLoop->getHeader()); TimeRegion PassTimer(getPassTimer(P)); + P->setExecuted(true); Changed |= P->runOnLoop(CurrentLoop, *this); } LoopWasDeleted = CurrentLoop->isInvalid(); -- cgit v1.2.3