Index: llvm/include/llvm/IR/LegacyPassManagers.h =================================================================== --- llvm/include/llvm/IR/LegacyPassManagers.h +++ llvm/include/llvm/IR/LegacyPassManagers.h @@ -330,7 +330,7 @@ /// through getAnalysis interface. virtual void addLowerLevelRequiredPass(Pass *P, Pass *RequiredPass); - virtual Pass *getOnTheFlyPass(Pass *P, AnalysisID PI, Function &F); + virtual Pass *getOnTheFlyAnalysis(Pass *P, AnalysisID PI, Function &F); /// Initialize available analysis information. void initializeAnalysisInfo() { Index: llvm/lib/IR/LegacyPassManager.cpp =================================================================== --- llvm/lib/IR/LegacyPassManager.cpp +++ llvm/lib/IR/LegacyPassManager.cpp @@ -437,7 +437,7 @@ /// Return function pass corresponding to PassInfo PI, that is /// required by module pass MP. Instantiate analysis pass, by using /// its runOnFunction() for function F. - Pass* getOnTheFlyPass(Pass *MP, AnalysisID PI, Function &F) override; + Pass *getOnTheFlyAnalysis(Pass *MP, AnalysisID PI, Function &F) override; StringRef getPassName() const override { return "Module Pass Manager"; } @@ -1290,8 +1290,8 @@ llvm_unreachable("Unable to schedule pass"); } -Pass *PMDataManager::getOnTheFlyPass(Pass *P, AnalysisID PI, Function &F) { - llvm_unreachable("Unable to find on the fly pass"); +Pass *PMDataManager::getOnTheFlyAnalysis(Pass *P, AnalysisID PI, Function &F) { + llvm_unreachable("Unable to find on the fly analysis"); } // Destructor @@ -1309,7 +1309,7 @@ Pass *AnalysisResolver::findImplPass(Pass *P, AnalysisID AnalysisPI, Function &F) { - return PM.getOnTheFlyPass(P, AnalysisPI, F); + return PM.getOnTheFlyAnalysis(P, AnalysisPI, F); } //===----------------------------------------------------------------------===// @@ -1665,16 +1665,17 @@ /// Return function pass corresponding to PassInfo PI, that is /// required by module pass MP. Instantiate analysis pass, by using /// its runOnFunction() for function F. -Pass* MPPassManager::getOnTheFlyPass(Pass *MP, AnalysisID PI, Function &F){ +Pass *MPPassManager::getOnTheFlyAnalysis(Pass *MP, AnalysisID PI, Function &F) { FunctionPassManagerImpl *FPP = OnTheFlyManagers[MP]; assert(FPP && "Unable to find on the fly pass"); FPP->releaseMemoryOnTheFly(); - FPP->run(F); + bool Changed = FPP->run(F); + assert(!Changed && "An analysis pass shouldn't modify its content."); + (void)Changed; return ((PMTopLevelManager*)FPP)->findAnalysisPass(PI); } - //===----------------------------------------------------------------------===// // PassManagerImpl implementation Index: llvm/lib/Transforms/IPO/LoopExtractor.cpp =================================================================== --- llvm/lib/Transforms/IPO/LoopExtractor.cpp +++ llvm/lib/Transforms/IPO/LoopExtractor.cpp @@ -18,6 +18,7 @@ #include "llvm/Analysis/LoopInfo.h" #include "llvm/IR/Dominators.h" #include "llvm/IR/Instructions.h" +#include "llvm/IR/LegacyPassManager.h" #include "llvm/IR/Module.h" #include "llvm/InitializePasses.h" #include "llvm/Pass.h" @@ -55,11 +56,9 @@ bool extractLoop(Loop *L, LoopInfo &LI, DominatorTree &DT); void getAnalysisUsage(AnalysisUsage &AU) const override { - AU.addRequiredID(BreakCriticalEdgesID); AU.addRequired(); AU.addRequired(); AU.addPreserved(); - AU.addRequiredID(LoopSimplifyID); AU.addUsedIfAvailable(); } }; @@ -68,10 +67,8 @@ char LoopExtractor::ID = 0; INITIALIZE_PASS_BEGIN(LoopExtractor, "loop-extract", "Extract loops into new functions", false, false) -INITIALIZE_PASS_DEPENDENCY(BreakCriticalEdges) INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass) -INITIALIZE_PASS_DEPENDENCY(LoopSimplify) INITIALIZE_PASS_END(LoopExtractor, "loop-extract", "Extract loops into new functions", false, false) @@ -131,18 +128,23 @@ if (F.empty()) return false; + legacy::FunctionPassManager FPM(F.getParent()); + FPM.add(createBreakCriticalEdgesPass()); + FPM.add(createLoopSimplifyPass()); + bool Changed = FPM.run(F); + LoopInfo &LI = getAnalysis(F).getLoopInfo(); // If there are no loops in the function. if (LI.empty()) - return false; + return Changed; DominatorTree &DT = getAnalysis(F).getDomTree(); // If there is more than one top-level loop in this function, extract all of // the loops. if (std::next(LI.begin()) != LI.end()) - return extractLoops(LI.begin(), LI.end(), LI, DT); + return Changed | extractLoops(LI.begin(), LI.end(), LI, DT); // Otherwise there is exactly one top-level loop. Loop *TLL = *LI.begin(); @@ -171,14 +173,14 @@ } if (ShouldExtractLoop) - return extractLoop(TLL, LI, DT); + return Changed | extractLoop(TLL, LI, DT); } // Okay, this function is a minimal container around the specified loop. // If we extract the loop, we will continue to just keep extracting it // infinitely... so don't extract it. However, if the loop contains any // sub-loops, extract them. - return extractLoops(TLL->begin(), TLL->end(), LI, DT); + return Changed | extractLoops(TLL->begin(), TLL->end(), LI, DT); } bool LoopExtractor::extractLoops(Loop::iterator From, Loop::iterator To,