Expose new "recalculate" method from dominatorset
llvm-svn: 4074
This commit is contained in:
parent
8d72b87dc5
commit
acb038e5c7
|
|
@ -128,6 +128,11 @@ struct DominatorSet : public DominatorSetBase {
|
||||||
|
|
||||||
virtual bool runOnFunction(Function &F);
|
virtual bool runOnFunction(Function &F);
|
||||||
|
|
||||||
|
/// recalculate - This method may be called by external passes that modify the
|
||||||
|
/// CFG and then need dominator information recalculated. This method is
|
||||||
|
/// obviously really slow, so it should be avoided if at all possible.
|
||||||
|
void recalculate();
|
||||||
|
|
||||||
// getAnalysisUsage - This simply provides a dominator set
|
// getAnalysisUsage - This simply provides a dominator set
|
||||||
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||||
AU.setPreservesAll();
|
AU.setPreservesAll();
|
||||||
|
|
|
||||||
|
|
@ -92,10 +92,15 @@ void DominatorSet::calculateDominatorsFromBlock(BasicBlock *RootBB) {
|
||||||
// specified function.
|
// specified function.
|
||||||
//
|
//
|
||||||
bool DominatorSet::runOnFunction(Function &F) {
|
bool DominatorSet::runOnFunction(Function &F) {
|
||||||
Doms.clear(); // Reset from the last time we were run...
|
|
||||||
Root = &F.getEntryNode();
|
Root = &F.getEntryNode();
|
||||||
assert(pred_begin(Root) == pred_end(Root) &&
|
assert(pred_begin(Root) == pred_end(Root) &&
|
||||||
"Root node has predecessors in function!");
|
"Root node has predecessors in function!");
|
||||||
|
recalculate();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DominatorSet::recalculate() {
|
||||||
|
Doms.clear(); // Reset from the last time we were run...
|
||||||
|
|
||||||
// Calculate dominator sets for the reachable basic blocks...
|
// Calculate dominator sets for the reachable basic blocks...
|
||||||
calculateDominatorsFromBlock(Root);
|
calculateDominatorsFromBlock(Root);
|
||||||
|
|
@ -106,11 +111,10 @@ bool DominatorSet::runOnFunction(Function &F) {
|
||||||
// extra pass over the function, calculating dominator information for
|
// extra pass over the function, calculating dominator information for
|
||||||
// unreachable blocks.
|
// unreachable blocks.
|
||||||
//
|
//
|
||||||
for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I)
|
Function *F = Root->getParent();
|
||||||
|
for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I)
|
||||||
if (Doms[I].count(I) == 0)
|
if (Doms[I].count(I) == 0)
|
||||||
calculateDominatorsFromBlock(I);
|
calculateDominatorsFromBlock(I);
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue