diff options
| -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() |