diff --git a/decompiler/pipeline/ssa/phi_lifting.py b/decompiler/pipeline/ssa/phi_lifting.py index 5d37357ae..4ef0e521a 100644 --- a/decompiler/pipeline/ssa/phi_lifting.py +++ b/decompiler/pipeline/ssa/phi_lifting.py @@ -54,6 +54,8 @@ def _lift_phi_functions_of(self, basic_block: BasicBlock) -> None: new_basic_block = self._insert_basic_block_before(basic_block, new_instructions) if predecessor: self._cfg.substitute_edge(edge, edge.copy(sink=new_basic_block)) + else: + self._cfg.root = new_basic_block self._update_interference_graph_after_lifting(new_instructions) diff --git a/tests/pipeline/SSA/test_out_of_ssa_phi_lifting.py b/tests/pipeline/SSA/test_out_of_ssa_phi_lifting.py index 0424abc47..f7b7fb4eb 100644 --- a/tests/pipeline/SSA/test_out_of_ssa_phi_lifting.py +++ b/tests/pipeline/SSA/test_out_of_ssa_phi_lifting.py @@ -287,6 +287,8 @@ def test_lifting_phi_on_top_1(variable_v, variable_u): and isinstance(phi_fct_lifter._cfg.get_edge(node, node), UnconditionalEdge) and len(phi_fct_lifter._cfg.edges) == 2 ) + # The root of the CFG must be updated by PhiFunctionLifter for the other stages to work + assert cfg.root == new_nodes[0] def test_lifting_phi_on_top_2(variable_v, variable_u): @@ -324,3 +326,5 @@ def test_lifting_phi_on_top_2(variable_v, variable_u): and isinstance(phi_fct_lifter._cfg.get_edge(node, node), UnconditionalEdge) and len(phi_fct_lifter._cfg.edges) == 2 ) + # The root of the CFG must be updated by PhiFunctionLifter for the other stages to work + assert cfg.root == new_nodes[0]