From: serge-sans-paille Date: Fri, 26 Jun 2020 13:23:05 +0000 (+0200) Subject: Fix pass return status for loop extractor X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=44f06db43941749b631756ff13cf7e8f7b2903fe;p=android-x86%2Fexternal-llvm-project.git Fix pass return status for loop extractor As loop extractor has a dependency on another pass (namely BreakCriticalEdges) that may update the IR, use the getAnalysis version introduced in 55fe7b79bb7fab49af3720840224c0720bdb03c6 to carry that change. Add an assert in getAnalysisID to make sure no other changed status is missed - according to validation this was the only one. Related to https://reviews.llvm.org/D80916 Differential Revision: https://reviews.llvm.org/D81236 --- diff --git a/llvm/include/llvm/PassAnalysisSupport.h b/llvm/include/llvm/PassAnalysisSupport.h index b41598ca9b7..d85a82e2cdd 100644 --- a/llvm/include/llvm/PassAnalysisSupport.h +++ b/llvm/include/llvm/PassAnalysisSupport.h @@ -270,6 +270,9 @@ AnalysisType &Pass::getAnalysisID(AnalysisID PI, Function &F, bool *Changed) { assert(ResultPass && "Unable to find requested analysis info"); if (Changed) *Changed |= LocalChanged; + else + assert(!LocalChanged && + "A pass trigged a code update but the update status is lost"); // Because the AnalysisType may not be a subclass of pass (for // AnalysisGroups), we use getAdjustedAnalysisPointer here to potentially diff --git a/llvm/lib/Transforms/IPO/LoopExtractor.cpp b/llvm/lib/Transforms/IPO/LoopExtractor.cpp index 14c39503e38..f7f5b4cf670 100644 --- a/llvm/lib/Transforms/IPO/LoopExtractor.cpp +++ b/llvm/lib/Transforms/IPO/LoopExtractor.cpp @@ -131,18 +131,19 @@ bool LoopExtractor::runOnFunction(Function &F) { if (F.empty()) return false; - LoopInfo &LI = getAnalysis(F).getLoopInfo(); + bool Changed = false; + LoopInfo &LI = getAnalysis(F, &Changed).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 +172,14 @@ bool LoopExtractor::runOnFunction(Function &F) { } 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,