/// DominatorTree - Calculate the immediate dominator tree for a function.
///
class DominatorTreeBase : public DominatorBase {
-public:
+
protected:
std::map<BasicBlock*, DomTreeNode*> DomTreeNodes;
void reset();
DomTreeNode *RootNode;
+ // Information record used during immediate dominators computation.
struct InfoRec {
unsigned Semi;
unsigned Size;
// Info - Collection of information used during the computation of idoms.
std::map<BasicBlock*, InfoRec> Info;
-public:
-public:
+ public:
DominatorTreeBase(intptr_t ID, bool isPostDom)
: DominatorBase(ID, isPostDom) {}
~DominatorTreeBase() { reset(); }
return DomTreeNodes[BB] = IDomNode->addChild(new DomTreeNode(BB, IDomNode));
}
+ void createNewNode(BasicBlock *BB, BasicBlock *DomBB) {
+ createNewNode(BB, getNode(DomBB));
+ }
+
/// changeImmediateDominator - This method is used to update the dominator
/// tree information when a node's immediate dominator changes.
///
N->setIDom(NewIDom);
}
+ void changeImmediateDominator(BasicBlock *BB, BasicBlock *NewBB) {
+ changeImmediateDominator(getNode(BB), getNode(NewBB));
+ }
+
+
/// removeNode - Removes a node from the dominator tree. Block must not
/// dominate any other blocks. Invalidates any node pointing to removed
/// block.
// blocks that dominate TIBB plus the new block itself.
if (EF) {
BasicBlock* idom = EF->getIDom(OldPred);
- DT->createNewNode(NewBB, DT->getNode(idom));
+ DT->createNewNode(NewBB, idom);
EF->addNewBlock(NewBB, idom);
// Additionally, NewBB replaces OldPred as the immediate dominator of blocks
Function *F = Header->getParent();
for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I)
if (EF->getIDom(I) == OldPred) {
- DT->changeImmediateDominator(DT->getNode(I), DT->getNode(NewBB));
+ DT->changeImmediateDominator(I, NewBB);
EF->setImmediateDominator(I, NewBB);
}
}