mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-30 02:25:19 +00:00
Preserve DominanceFrontier.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37820 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -84,6 +84,7 @@ namespace {
|
|||||||
AU.addRequiredID(LoopSimplifyID);
|
AU.addRequiredID(LoopSimplifyID);
|
||||||
AU.addPreservedID(LoopSimplifyID);
|
AU.addPreservedID(LoopSimplifyID);
|
||||||
AU.addPreserved<DominatorTree>();
|
AU.addPreserved<DominatorTree>();
|
||||||
|
AU.addPreserved<DominanceFrontier>();
|
||||||
AU.addRequired<LoopInfo>();
|
AU.addRequired<LoopInfo>();
|
||||||
AU.addPreserved<LoopInfo>();
|
AU.addPreserved<LoopInfo>();
|
||||||
AU.addRequiredID(LCSSAID);
|
AU.addRequiredID(LCSSAID);
|
||||||
@@ -415,6 +416,9 @@ BasicBlock *LoopUnswitch::SplitBlock(BasicBlock *Old, Instruction *SplitPt) {
|
|||||||
|
|
||||||
if (DominatorTree *DT = getAnalysisToUpdate<DominatorTree>())
|
if (DominatorTree *DT = getAnalysisToUpdate<DominatorTree>())
|
||||||
DT->addNewBlock(New, Old);
|
DT->addNewBlock(New, Old);
|
||||||
|
|
||||||
|
if (DominanceFrontier *DF = getAnalysisToUpdate<DominanceFrontier>())
|
||||||
|
DF->splitBlock(Old);
|
||||||
|
|
||||||
return New;
|
return New;
|
||||||
}
|
}
|
||||||
@@ -471,7 +475,7 @@ static inline void RemapInstruction(Instruction *I,
|
|||||||
// If Orig is in Loop then find and use Orig dominator's cloned block as NewBB
|
// If Orig is in Loop then find and use Orig dominator's cloned block as NewBB
|
||||||
// dominator.
|
// dominator.
|
||||||
void CloneDomInfo(BasicBlock *NewBB, BasicBlock *Orig, Loop *L,
|
void CloneDomInfo(BasicBlock *NewBB, BasicBlock *Orig, Loop *L,
|
||||||
DominatorTree *DT,
|
DominatorTree *DT, DominanceFrontier *DF,
|
||||||
DenseMap<const Value*, Value*> &VM) {
|
DenseMap<const Value*, Value*> &VM) {
|
||||||
|
|
||||||
DomTreeNode *OrigNode = DT->getNode(Orig);
|
DomTreeNode *OrigNode = DT->getNode(Orig);
|
||||||
@@ -481,7 +485,7 @@ void CloneDomInfo(BasicBlock *NewBB, BasicBlock *Orig, Loop *L,
|
|||||||
BasicBlock *NewIDom = OrigIDom;
|
BasicBlock *NewIDom = OrigIDom;
|
||||||
if (L->contains(OrigIDom)) {
|
if (L->contains(OrigIDom)) {
|
||||||
if (!DT->getNode(OrigIDom))
|
if (!DT->getNode(OrigIDom))
|
||||||
CloneDomInfo(NewIDom, OrigIDom, L, DT, VM);
|
CloneDomInfo(NewIDom, OrigIDom, L, DT, DF, VM);
|
||||||
NewIDom = cast<BasicBlock>(VM[OrigIDom]);
|
NewIDom = cast<BasicBlock>(VM[OrigIDom]);
|
||||||
}
|
}
|
||||||
if (NewBB == NewIDom) {
|
if (NewBB == NewIDom) {
|
||||||
@@ -489,6 +493,23 @@ void CloneDomInfo(BasicBlock *NewBB, BasicBlock *Orig, Loop *L,
|
|||||||
DT->changeImmediateDominator(NewBB, NewIDom);
|
DT->changeImmediateDominator(NewBB, NewIDom);
|
||||||
} else
|
} else
|
||||||
DT->addNewBlock(NewBB, NewIDom);
|
DT->addNewBlock(NewBB, NewIDom);
|
||||||
|
|
||||||
|
DominanceFrontier::DomSetType NewDFSet;
|
||||||
|
if (DF) {
|
||||||
|
DominanceFrontier::iterator DFI = DF->find(Orig);
|
||||||
|
if ( DFI != DF->end()) {
|
||||||
|
DominanceFrontier::DomSetType S = DFI->second;
|
||||||
|
for (DominanceFrontier::DomSetType::iterator I = S.begin(), E = S.end();
|
||||||
|
I != E; ++I) {
|
||||||
|
BasicBlock *BB = *I;
|
||||||
|
if (L->contains(BB))
|
||||||
|
NewDFSet.insert(cast<BasicBlock>(VM[Orig]));
|
||||||
|
else
|
||||||
|
NewDFSet.insert(BB);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DF->addBasicBlock(NewBB, NewDFSet);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// CloneLoop - Recursively clone the specified loop and all of its children,
|
/// CloneLoop - Recursively clone the specified loop and all of its children,
|
||||||
@@ -532,12 +553,14 @@ void LoopUnswitch::EmitPreheaderBranchOnCondition(Value *LIC, Constant *Val,
|
|||||||
BranchInst *BRI = new BranchInst(TrueDest, FalseDest, BranchVal, InsertPt);
|
BranchInst *BRI = new BranchInst(TrueDest, FalseDest, BranchVal, InsertPt);
|
||||||
|
|
||||||
// Update dominator info.
|
// Update dominator info.
|
||||||
|
// BranchVal is a new preheader so it dominates true and false destination
|
||||||
|
// loop headers.
|
||||||
if (DominatorTree *DT = getAnalysisToUpdate<DominatorTree>()) {
|
if (DominatorTree *DT = getAnalysisToUpdate<DominatorTree>()) {
|
||||||
// BranchVal is a new preheader so it dominates true and false destination
|
|
||||||
// loop headers.
|
|
||||||
DT->changeImmediateDominator(TrueDest, BRI->getParent());
|
DT->changeImmediateDominator(TrueDest, BRI->getParent());
|
||||||
DT->changeImmediateDominator(FalseDest, BRI->getParent());
|
DT->changeImmediateDominator(FalseDest, BRI->getParent());
|
||||||
}
|
}
|
||||||
|
// No need to update DominanceFrontier. BRI->getParent() dominated TrueDest
|
||||||
|
// and FalseDest anyway. Now it immediately dominates them.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -679,11 +702,12 @@ void LoopUnswitch::UnswitchNontrivialCondition(Value *LIC, Constant *Val,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update dominator info
|
// Update dominator info
|
||||||
|
DominanceFrontier *DF = getAnalysisToUpdate<DominanceFrontier>();
|
||||||
if (DominatorTree *DT = getAnalysisToUpdate<DominatorTree>())
|
if (DominatorTree *DT = getAnalysisToUpdate<DominatorTree>())
|
||||||
for (unsigned i = 0, e = LoopBlocks.size(); i != e; ++i) {
|
for (unsigned i = 0, e = LoopBlocks.size(); i != e; ++i) {
|
||||||
BasicBlock *LBB = LoopBlocks[i];
|
BasicBlock *LBB = LoopBlocks[i];
|
||||||
BasicBlock *NBB = NewBlocks[i];
|
BasicBlock *NBB = NewBlocks[i];
|
||||||
CloneDomInfo(NBB, LBB, L, DT, ValueMap);
|
CloneDomInfo(NBB, LBB, L, DT, DF, ValueMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Splice the newly inserted blocks into the function right before the
|
// Splice the newly inserted blocks into the function right before the
|
||||||
|
Reference in New Issue
Block a user