[PATCH] D81236: Correctly report modified status for LoopExtractor
serge via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 5 01:03:46 PDT 2020
serge-sans-paille created this revision.
serge-sans-paille added reviewers: ekatz, nikic, foad, jdoerfert.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
Related to https://reviews.llvm.org/D80916
Surprisingly, retrieving the analysis triggers a normalization step that may modify the BB graph (through the addition of a dummy exit BB)
https://reviews.llvm.org/D81236
Files:
llvm/lib/Transforms/IPO/LoopExtractor.cpp
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<LoopInfoWrapperPass>(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<DominatorTreeWrapperPass>(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,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81236.268689.patch
Type: text/x-patch
Size: 1719 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200605/aa7af830/attachment.bin>
More information about the llvm-commits
mailing list