summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorVikram TV <vikram.tarikere@gmail.com>2016-06-11 16:41:10 +0000
committerVikram TV <vikram.tarikere@gmail.com>2016-06-11 16:41:10 +0000
commitc702b8b3d76fe74db5fa4bf0e84858d83b16e619 (patch)
tree3fec67dbfb8b69f43f9c9ef0095565e8bccc7750 /llvm/lib/Transforms
parent2993ad22488045c916a131c41e2934e8cce9b0e7 (diff)
downloadbcm5719-llvm-c702b8b3d76fe74db5fa4bf0e84858d83b16e619.tar.gz
bcm5719-llvm-c702b8b3d76fe74db5fa4bf0e84858d83b16e619.zip
Delay dominator updation while cloning loop.
Summary: Dominator updation fails for a loop inserted with a new basicblock. A block required by DT to set the IDom might not have been cloned yet. This is because there is no predefined ordering of loop blocks (except for the header block which should be the first block in the list). The patch first creates DT nodes for the cloned blocks and then separately updates the DT in a follow-on loop. Reviewers: anemet, dberlin Subscribers: dberlin, llvm-commits Differential Revision: http://reviews.llvm.org/D20899 llvm-svn: 272479
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Utils/CloneFunction.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp
index b64fdbd7b1a..6ff05fe3e59 100644
--- a/llvm/lib/Transforms/Utils/CloneFunction.cpp
+++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp
@@ -688,13 +688,19 @@ Loop *llvm::cloneLoopWithPreheader(BasicBlock *Before, BasicBlock *LoopDomBB,
// Update LoopInfo.
NewLoop->addBasicBlockToLoop(NewBB, *LI);
- // Update DominatorTree.
- BasicBlock *IDomBB = DT->getNode(BB)->getIDom()->getBlock();
- DT->addNewBlock(NewBB, cast<BasicBlock>(VMap[IDomBB]));
+ // Add DominatorTree node. After seeing all blocks, update to correct IDom.
+ DT->addNewBlock(NewBB, NewPH);
Blocks.push_back(NewBB);
}
+ for (BasicBlock *BB : OrigLoop->getBlocks()) {
+ // Update DominatorTree.
+ BasicBlock *IDomBB = DT->getNode(BB)->getIDom()->getBlock();
+ DT->changeImmediateDominator(cast<BasicBlock>(VMap[BB]),
+ cast<BasicBlock>(VMap[IDomBB]));
+ }
+
// Move them physically from the end of the block list.
F->getBasicBlockList().splice(Before->getIterator(), F->getBasicBlockList(),
NewPH);
OpenPOWER on IntegriCloud