[llvm-commits] [llvm] r41052 - in /llvm/trunk: include/llvm/Analysis/Dominators.h lib/VMCore/Dominators.cpp
Devang Patel
dpatel at apple.com
Mon Aug 13 15:10:29 PDT 2007
Author: dpatel
Date: Mon Aug 13 17:10:29 2007
New Revision: 41052
URL: http://llvm.org/viewvc/llvm-project?rev=41052&view=rev
Log:
Add methods to erase basic block entry.
Modified:
llvm/trunk/include/llvm/Analysis/Dominators.h
llvm/trunk/lib/VMCore/Dominators.cpp
Modified: llvm/trunk/include/llvm/Analysis/Dominators.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/Dominators.h?rev=41052&r1=41051&r2=41052&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/Dominators.h (original)
+++ llvm/trunk/include/llvm/Analysis/Dominators.h Mon Aug 13 17:10:29 2007
@@ -253,6 +253,11 @@
changeImmediateDominator(getNode(BB), getNode(NewBB));
}
+ /// eraseNode - Removes a node from the domiantor tree. Block must not
+ /// domiante any other blocks. Removes node from its immediate dominator's
+ /// children list. Deletes dominator node associated with basic block BB.
+ void eraseNode(BasicBlock *BB);
+
/// removeNode - Removes a node from the dominator tree. Block must not
/// dominate any other blocks. Invalidates any node pointing to removed
/// block.
@@ -370,6 +375,13 @@
Frontiers.insert(std::make_pair(BB, frontier));
}
+ /// removeBlock - Remove basic block BB's frontier.
+ void removeBlock(BasicBlock *BB) {
+ assert(find(BB) != end() && "Block is not in DominanceFrontier!");
+ iterator BBDF = Frontiers.find(BB);
+ Frontiers.erase(BBDF);
+ }
+
void addToFrontier(iterator I, BasicBlock *Node) {
assert(I != end() && "BB is not in DominanceFrontier!");
I->second.insert(Node);
Modified: llvm/trunk/lib/VMCore/Dominators.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Dominators.cpp?rev=41052&r1=41051&r2=41052&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Dominators.cpp (original)
+++ llvm/trunk/lib/VMCore/Dominators.cpp Mon Aug 13 17:10:29 2007
@@ -559,6 +559,30 @@
PrintDomTree(*I, o, Lev+1);
}
+/// eraseNode - Removes a node from the domiantor tree. Block must not
+/// domiante any other blocks. Removes node from its immediate dominator's
+/// children list. Deletes dominator node associated with basic block BB.
+void DominatorTreeBase::eraseNode(BasicBlock *BB) {
+ DomTreeNode *Node = getNode(BB);
+ assert (Node && "Removing node that isn't in dominator tree.");
+
+ // Remove node from immediate dominator's children list.
+ DomTreeNode *IDom = Node->getIDom();
+ if (IDom) {
+ std::vector<DomTreeNode*>::iterator I =
+ std::find(IDom->Children.begin(), IDom->Children.end(), Node);
+ assert(I != IDom->Children.end() &&
+ "Not in immediate dominator children set!");
+ // I am no longer your child...
+ IDom->Children.erase(I);
+ }
+
+ assert (Node->getChildren().empty() && "Children list is not empty");
+
+ DomTreeNodes.erase(BB);
+ delete Node;
+}
+
void DominatorTreeBase::print(std::ostream &o, const Module* ) const {
o << "=============================--------------------------------\n";
o << "Inorder Dominator Tree: ";
More information about the llvm-commits
mailing list