diff options
Diffstat (limited to 'llvm/lib/Analysis/LoopPass.cpp')
| -rw-r--r-- | llvm/lib/Analysis/LoopPass.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/LoopPass.cpp b/llvm/lib/Analysis/LoopPass.cpp index 520f06003dd2..9e470e998e67 100644 --- a/llvm/lib/Analysis/LoopPass.cpp +++ b/llvm/lib/Analysis/LoopPass.cpp @@ -15,11 +15,12 @@ #include "llvm/Analysis/LoopPass.h" #include "llvm/Analysis/LoopAnalysisManager.h" #include "llvm/IR/Dominators.h" -#include "llvm/IR/IRPrintingPasses.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/OptBisect.h" #include "llvm/IR/PassManager.h" #include "llvm/IR/PassTimingInfo.h" +#include "llvm/IR/PrintPasses.h" +#include "llvm/IR/StructuralHash.h" #include "llvm/InitializePasses.h" #include "llvm/Support/Debug.h" #include "llvm/Support/TimeProfiler.h" @@ -76,7 +77,7 @@ LPPassManager::LPPassManager() // Insert loop into loop nest (LoopInfo) and loop queue (LQ). void LPPassManager::addLoop(Loop &L) { - if (!L.getParentLoop()) { + if (L.isOutermost()) { // This is the top level loop. LQ.push_front(&L); return; @@ -116,7 +117,7 @@ void LPPassManager::markLoopAsDeleted(Loop &L) { // there. However, we have to be careful to not remove the back of the queue // as that is assumed to match the current loop. assert(LQ.back() == CurrentLoop && "Loop queue back isn't the current loop!"); - LQ.erase(std::remove(LQ.begin(), LQ.end(), &L), LQ.end()); + llvm::erase_value(LQ, &L); if (&L == CurrentLoop) { CurrentLoopDeleted = true; @@ -191,7 +192,19 @@ bool LPPassManager::runOnFunction(Function &F) { { PassManagerPrettyStackEntry X(P, *CurrentLoop->getHeader()); TimeRegion PassTimer(getPassTimer(P)); +#ifdef EXPENSIVE_CHECKS + uint64_t RefHash = StructuralHash(F); +#endif LocalChanged = P->runOnLoop(CurrentLoop, *this); + +#ifdef EXPENSIVE_CHECKS + if (!LocalChanged && (RefHash != StructuralHash(F))) { + llvm::errs() << "Pass modifies its input and doesn't report it: " + << P->getPassName() << "\n"; + llvm_unreachable("Pass modifies its input and doesn't report it"); + } +#endif + Changed |= LocalChanged; if (EmitICRemark) { unsigned NewSize = F.getInstructionCount(); @@ -241,7 +254,8 @@ bool LPPassManager::runOnFunction(Function &F) { F.getContext().yield(); } - removeNotPreservedAnalysis(P); + if (LocalChanged) + removeNotPreservedAnalysis(P); recordAvailableAnalysis(P); removeDeadPasses(P, CurrentLoopDeleted ? "<deleted>" |
