diff options
| author | Ajax <commial@gmail.com> | 2016-03-09 10:30:52 +0100 |
|---|---|---|
| committer | Ajax <commial@gmail.com> | 2016-03-09 10:30:52 +0100 |
| commit | 7a8162c4f5b9f577145a4912f492b221151a78da (patch) | |
| tree | f689c6b977e38bca0ea648786a0cb48f12c7fb4e | |
| parent | 9c4d5276b8b29d6f900c8184939468b028933cee (diff) | |
| download | miasm-7a8162c4f5b9f577145a4912f492b221151a78da.tar.gz miasm-7a8162c4f5b9f577145a4912f492b221151a78da.zip | |
Speed up _block_merge
| -rw-r--r-- | miasm2/core/asmbloc.py | 11 |
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() |