diff options
author | Devang Patel <dpatel@apple.com> | 2007-08-13 22:10:29 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2007-08-13 22:10:29 +0000 |
commit | 441c5ee6cfd4fdec78d7d86536610b2e72519450 (patch) | |
tree | e721b98be826242b8cfb4d48a37919721e180820 /lib/VMCore | |
parent | 6acc9e6b7bc5cc5b45a69988b2805674da62a820 (diff) | |
download | external_llvm-441c5ee6cfd4fdec78d7d86536610b2e72519450.zip external_llvm-441c5ee6cfd4fdec78d7d86536610b2e72519450.tar.gz external_llvm-441c5ee6cfd4fdec78d7d86536610b2e72519450.tar.bz2 |
Add methods to erase basic block entry.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41052 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/Dominators.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/VMCore/Dominators.cpp b/lib/VMCore/Dominators.cpp index d08048c..d292e08 100644 --- a/lib/VMCore/Dominators.cpp +++ b/lib/VMCore/Dominators.cpp @@ -559,6 +559,30 @@ static void PrintDomTree(const DomTreeNode *N, std::ostream &o, 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: "; |