[PATCH] D15922: [Cloning] rename cloneLoopWithPreheader() and add assert to ensure no sub-loops
Vaivaswatha Nagaraj via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 18 21:54:08 PDT 2016
vaivaswatha updated this revision to Diff 54156.
vaivaswatha added a comment.
Updating based on review comments
http://reviews.llvm.org/D15922
Files:
include/llvm/Transforms/Utils/Cloning.h
lib/Transforms/Scalar/LoopDistribute.cpp
lib/Transforms/Utils/CloneFunction.cpp
lib/Transforms/Utils/LoopVersioning.cpp
Index: lib/Transforms/Utils/LoopVersioning.cpp
===================================================================
--- lib/Transforms/Utils/LoopVersioning.cpp
+++ lib/Transforms/Utils/LoopVersioning.cpp
@@ -102,7 +102,7 @@
// block is a join between the two loops.
SmallVector<BasicBlock *, 8> NonVersionedLoopBlocks;
NonVersionedLoop =
- cloneLoopWithPreheader(PH, RuntimeCheckBB, VersionedLoop, VMap,
+ cloneInnermostLoopWithPreheader(PH, RuntimeCheckBB, VersionedLoop, VMap,
".lver.orig", LI, DT, NonVersionedLoopBlocks);
remapInstructionsInBlocks(NonVersionedLoopBlocks, VMap);
Index: lib/Transforms/Utils/CloneFunction.cpp
===================================================================
--- lib/Transforms/Utils/CloneFunction.cpp
+++ lib/Transforms/Utils/CloneFunction.cpp
@@ -702,11 +702,15 @@
///
/// Updates LoopInfo and DominatorTree assuming the loop is dominated by block
/// \p LoopDomBB. Insert the new blocks before block specified in \p Before.
-Loop *llvm::cloneLoopWithPreheader(BasicBlock *Before, BasicBlock *LoopDomBB,
+/// \p OrigLoop should not have sub-loops.
+Loop *llvm::cloneInnermostLoopWithPreheader(BasicBlock *Before,
+ BasicBlock *LoopDomBB,
Loop *OrigLoop, ValueToValueMapTy &VMap,
const Twine &NameSuffix, LoopInfo *LI,
DominatorTree *DT,
SmallVectorImpl<BasicBlock *> &Blocks) {
+ assert(OrigLoop->getSubLoops().empty() &&
+ "Loop to be cloned cannot have inner loop");
Function *F = OrigLoop->getHeader()->getParent();
Loop *ParentLoop = OrigLoop->getParentLoop();
Index: lib/Transforms/Scalar/LoopDistribute.cpp
===================================================================
--- lib/Transforms/Scalar/LoopDistribute.cpp
+++ lib/Transforms/Scalar/LoopDistribute.cpp
@@ -122,10 +122,12 @@
///
/// Updates LoopInfo and DominatorTree using the information that block \p
/// LoopDomBB dominates the loop.
- Loop *cloneLoopWithPreheader(BasicBlock *InsertBefore, BasicBlock *LoopDomBB,
+ Loop *cloneInnermostLoopWithPreheader(BasicBlock *InsertBefore,
+ BasicBlock *LoopDomBB,
unsigned Index, LoopInfo *LI,
DominatorTree *DT) {
- ClonedLoop = ::cloneLoopWithPreheader(InsertBefore, LoopDomBB, OrigLoop,
+ ClonedLoop = ::cloneInnermostLoopWithPreheader(InsertBefore, LoopDomBB,
+ OrigLoop,
VMap, Twine(".ldist") + Twine(Index),
LI, DT, ClonedLoopBlocks);
return ClonedLoop;
@@ -403,16 +405,17 @@
I != E; ++I, --Index, TopPH = NewLoop->getLoopPreheader()) {
auto *Part = &*I;
- NewLoop = Part->cloneLoopWithPreheader(TopPH, Pred, Index, LI, DT);
+ NewLoop = Part->cloneInnermostLoopWithPreheader
+ (TopPH, Pred, Index, LI, DT);
Part->getVMap()[ExitBlock] = TopPH;
Part->remapInstructions();
}
Pred->getTerminator()->replaceUsesOfWith(OrigPH, TopPH);
// Now go in forward order and update the immediate dominator for the
// preheaders with the exiting block of the previous loop. Dominance
- // within the loop is updated in cloneLoopWithPreheader.
+ // within the loop is updated in cloneInnermostLoopWithPreheader.
for (auto Curr = PartitionContainer.cbegin(),
Next = std::next(PartitionContainer.cbegin()),
E = PartitionContainer.cend();
Index: include/llvm/Transforms/Utils/Cloning.h
===================================================================
--- include/llvm/Transforms/Utils/Cloning.h
+++ include/llvm/Transforms/Utils/Cloning.h
@@ -221,7 +221,8 @@
///
/// Updates LoopInfo and DominatorTree assuming the loop is dominated by block
/// \p LoopDomBB. Insert the new blocks before block specified in \p Before.
-Loop *cloneLoopWithPreheader(BasicBlock *Before, BasicBlock *LoopDomBB,
+/// \p OrigLoop should not have sub-loops.
+Loop *cloneInnermostLoopWithPreheader(BasicBlock *Before, BasicBlock *LoopDomBB,
Loop *OrigLoop, ValueToValueMapTy &VMap,
const Twine &NameSuffix, LoopInfo *LI,
DominatorTree *DT,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15922.54156.patch
Type: text/x-patch
Size: 4467 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160419/6d597355/attachment.bin>
More information about the llvm-commits
mailing list