about summary refs log tree commit diff stats
path: root/miasm2/core/graph.py
diff options
context:
space:
mode:
authorTim Blazytko <tim.blazytko@rub.de>2015-05-10 00:35:20 +0200
committerTim Blazytko <tim.blazytko@rub.de>2015-06-02 14:56:08 +0200
commit6c2f49b969dbb2d4490ff2aa150a00086280b116 (patch)
treea22cba23aa8d3b3f55202010d51249722bd3f461 /miasm2/core/graph.py
parent1cd6af8fa196f9ce799e383aa8897d9ad35bb2d2 (diff)
downloadmiasm-6c2f49b969dbb2d4490ff2aa150a00086280b116.tar.gz
miasm-6c2f49b969dbb2d4490ff2aa150a00086280b116.zip
graph.py: added computation of immediate dominators
Diffstat (limited to 'miasm2/core/graph.py')
-rw-r--r--miasm2/core/graph.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/miasm2/core/graph.py b/miasm2/core/graph.py
index 47be1864..c647ede8 100644
--- a/miasm2/core/graph.py
+++ b/miasm2/core/graph.py
@@ -300,3 +300,15 @@ shape = "box"
         return self._walk_generic_dominator(node,
                                             postdominators,
                                             self.successors_iter)
+
+    def compute_immediate_dominators(self, head):
+        """Compute the immediate dominators of the graph"""
+        dominators = self.compute_dominators(head)
+        idoms = {}
+
+        for n in dominators.keys():
+            for p in self.reachable_parents(n):
+                if p in dominators[n] and n != p:
+                    idoms[n] = p
+                    break
+        return idoms