[CloneFunction] Preserve DT in DuplicateInstructionsInSplitBetween.

DuplicateInstructionsInSplitBetween can preserve the DT by passing
through DT to SplitEdge.

Reviewers: sanjoy, junbuml, anna, kuhar

Reviewed By: kuhar

Differential Revision: https://reviews.llvm.org/D44629

llvm-svn: 328189
This commit is contained in:
Florian Hahn 2018-03-22 11:38:53 +00:00
parent 7e69dd02bb
commit 3bb822e7d6
2 changed files with 5 additions and 3 deletions

View File

@ -265,7 +265,8 @@ void remapInstructionsInBlocks(const SmallVectorImpl<BasicBlock *> &Blocks,
BasicBlock *
DuplicateInstructionsInSplitBetween(BasicBlock *BB, BasicBlock *PredBB,
Instruction *StopAt,
ValueToValueMapTy &ValueMapping);
ValueToValueMapTy &ValueMapping,
DominatorTree *DT = nullptr);
} // end namespace llvm
#endif // LLVM_TRANSFORMS_UTILS_CLONING_H

View File

@ -797,7 +797,8 @@ Loop *llvm::cloneLoopWithPreheader(BasicBlock *Before, BasicBlock *LoopDomBB,
BasicBlock *
llvm::DuplicateInstructionsInSplitBetween(BasicBlock *BB, BasicBlock *PredBB,
Instruction *StopAt,
ValueToValueMapTy &ValueMapping) {
ValueToValueMapTy &ValueMapping,
DominatorTree *DT) {
// We are going to have to map operands from the original BB block to the new
// copy of the block 'NewBB'. If there are PHI nodes in BB, evaluate them to
// account for entry from PredBB.
@ -805,7 +806,7 @@ llvm::DuplicateInstructionsInSplitBetween(BasicBlock *BB, BasicBlock *PredBB,
for (; PHINode *PN = dyn_cast<PHINode>(BI); ++BI)
ValueMapping[PN] = PN->getIncomingValueForBlock(PredBB);
BasicBlock *NewBB = SplitEdge(PredBB, BB);
BasicBlock *NewBB = SplitEdge(PredBB, BB, DT);
NewBB->setName(PredBB->getName() + ".split");
Instruction *NewTerm = NewBB->getTerminator();