Index: llvm/lib/Transforms/IPO/LoopExtractor.cpp =================================================================== --- llvm/lib/Transforms/IPO/LoopExtractor.cpp +++ llvm/lib/Transforms/IPO/LoopExtractor.cpp @@ -131,18 +131,24 @@ if (F.empty()) return false; + unsigned BBCount = F.size(); LoopInfo &LI = getAnalysis(F).getLoopInfo(); + // This is only needed because of a violation of the analysis contract: + // LoopInfoWrapperPass normalizes the loop which may lead to code change + bool Modified = BBCount != F.size(); + // If there are no loops in the function. if (LI.empty()) - return false; + return Modified; 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 Modified | extractLoops(LI.begin(), LI.end(), LI, DT); + // Otherwise there is exactly one top-level loop. Loop *TLL = *LI.begin(); @@ -171,14 +177,14 @@ } if (ShouldExtractLoop) - return extractLoop(TLL, LI, DT); + return Modified | 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 Modified | extractLoops(TLL->begin(), TLL->end(), LI, DT); } bool LoopExtractor::extractLoops(Loop::iterator From, Loop::iterator To,