about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorserpilliere <serpilliere@users.noreply.github.com>2016-03-09 11:11:19 +0100
committerserpilliere <serpilliere@users.noreply.github.com>2016-03-09 11:11:19 +0100
commit8c074bac42595831d8f8bad4a6cd25da567e1336 (patch)
treef689c6b977e38bca0ea648786a0cb48f12c7fb4e
parent9c4d5276b8b29d6f900c8184939468b028933cee (diff)
parent7a8162c4f5b9f577145a4912f492b221151a78da (diff)
downloadmiasm-8c074bac42595831d8f8bad4a6cd25da567e1336.tar.gz
miasm-8c074bac42595831d8f8bad4a6cd25da567e1336.zip
Merge pull request #332 from commial/block_merge_speedup
Speed up block merging
-rw-r--r--miasm2/core/asmbloc.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/miasm2/core/asmbloc.py b/miasm2/core/asmbloc.py
index 6e568740..e1f66562 100644
--- a/miasm2/core/asmbloc.py
+++ b/miasm2/core/asmbloc.py
@@ -978,11 +978,20 @@ _expgraph = _parent >> _son
 def _merge_blocks(dg, graph):
     """Graph simplification merging asm_bloc with one and only one son with this
     son if this son has one and only one parent"""
+
+    # Blocks to ignore, because they have been removed from the graph
+    to_ignore = set()
+
     for match in _expgraph.match(graph):
 
         # Get matching blocks
         block, succ = match[_parent], match[_son]
 
+        # Ignore already deleted blocks
+        if (block in to_ignore or
+            succ in to_ignore):
+            continue
+
         # Remove block last instruction if needed
         last_instr = block.lines[-1]
         if last_instr.delayslot > 0:
@@ -1000,7 +1009,7 @@ def _merge_blocks(dg, graph):
             graph.add_edge(block, nextb, graph.edges2constraint[(succ, nextb)])
 
         graph.del_node(succ)
-        break
+        to_ignore.add(succ)
 
 
 bbl_simplifier = DiGraphSimplifier()