aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore/Dominators.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-09-26 16:14:41 +0000
committerChris Lattner <sabre@nondot.org>2002-09-26 16:14:41 +0000
commitd74472ed21b1ff6d75c8ae2f4f2885e019d0907d (patch)
tree8f1ab2280f918c7332e391d4ea1531a5b7932bf4 /lib/VMCore/Dominators.cpp
parent3a294d6085c69ad7ac1572a2c976624efe66a082 (diff)
downloadexternal_llvm-d74472ed21b1ff6d75c8ae2f4f2885e019d0907d.zip
external_llvm-d74472ed21b1ff6d75c8ae2f4f2885e019d0907d.tar.gz
external_llvm-d74472ed21b1ff6d75c8ae2f4f2885e019d0907d.tar.bz2
- Add methods to ImmediateDominators & DominatorTree to allow updates
- Make DominatorTree::Node not inherit from std::vector git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3939 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Dominators.cpp')
-rw-r--r--lib/VMCore/Dominators.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/VMCore/Dominators.cpp b/lib/VMCore/Dominators.cpp
index cd0825c..e6f18ec 100644
--- a/lib/VMCore/Dominators.cpp
+++ b/lib/VMCore/Dominators.cpp
@@ -186,6 +186,23 @@ void DominatorTreeBase::reset() {
Nodes.clear();
}
+void DominatorTreeBase::Node2::setIDom(Node2 *NewIDom) {
+ assert(IDom && "No immediate dominator?");
+ if (IDom != NewIDom) {
+ std::vector<Node*>::iterator I =
+ std::find(IDom->Children.begin(), IDom->Children.end(), this);
+ assert(I != IDom->Children.end() &&
+ "Not in immediate dominator children set!");
+ // I am no longer your child...
+ IDom->Children.erase(I);
+
+ // Switch to new dominator
+ IDom = NewIDom;
+ IDom->Children.push_back(this);
+ }
+}
+
+
void DominatorTree::calculate(const DominatorSet &DS) {
Nodes[Root] = new Node(Root, 0); // Add a node for the root...