mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-12 13:38:21 +00:00
Give SplitBlockAndInsertIfThen the ability to update a domtree.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213045 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -673,7 +673,8 @@ ReturnInst *llvm::FoldReturnIntoUncondBranch(ReturnInst *RI, BasicBlock *BB,
|
||||
TerminatorInst *llvm::SplitBlockAndInsertIfThen(Value *Cond,
|
||||
Instruction *SplitBefore,
|
||||
bool Unreachable,
|
||||
MDNode *BranchWeights) {
|
||||
MDNode *BranchWeights,
|
||||
DominatorTree *DT) {
|
||||
BasicBlock *Head = SplitBefore->getParent();
|
||||
BasicBlock *Tail = Head->splitBasicBlock(SplitBefore);
|
||||
TerminatorInst *HeadOldTerm = Head->getTerminator();
|
||||
@ -690,6 +691,20 @@ TerminatorInst *llvm::SplitBlockAndInsertIfThen(Value *Cond,
|
||||
HeadNewTerm->setDebugLoc(SplitBefore->getDebugLoc());
|
||||
HeadNewTerm->setMetadata(LLVMContext::MD_prof, BranchWeights);
|
||||
ReplaceInstWithInst(HeadOldTerm, HeadNewTerm);
|
||||
|
||||
if (DT) {
|
||||
if (DomTreeNode *OldNode = DT->getNode(Head)) {
|
||||
std::vector<DomTreeNode *> Children(OldNode->begin(), OldNode->end());
|
||||
|
||||
DomTreeNode *NewNode = DT->addNewBlock(Tail, Head);
|
||||
for (auto Child : Children)
|
||||
DT->changeImmediateDominator(Child, NewNode);
|
||||
|
||||
// Head dominates ThenBlock.
|
||||
DT->addNewBlock(ThenBlock, Head);
|
||||
}
|
||||
}
|
||||
|
||||
return CheckTerm;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user