From 2565049ad8bf14f2e990f326490766ebf35cc4a1 Mon Sep 17 00:00:00 2001 From: alexcere <48130030+alexcere@users.noreply.github.com> Date: Wed, 20 Nov 2024 09:37:41 +0100 Subject: [PATCH] Compute final stack elements from the split instruction --- src/cfg_methods/cfg_block_actions/merge_blocks.py | 1 - src/cfg_methods/variable_renaming.py | 1 - src/parser/cfg_block.py | 6 +----- src/parser/optimizable_block_list.py | 3 +-- 4 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/cfg_methods/cfg_block_actions/merge_blocks.py b/src/cfg_methods/cfg_block_actions/merge_blocks.py index af549661..bbe3400e 100644 --- a/src/cfg_methods/cfg_block_actions/merge_blocks.py +++ b/src/cfg_methods/cfg_block_actions/merge_blocks.py @@ -82,7 +82,6 @@ def _update_cfg_edges(self): self._combined_block.set_comes_from(predecessor_ids_first + predecessor_ids_second) self._combined_block.set_jump_to(jumps_to_id) self._combined_block.set_falls_to(falls_to_id) - self._combined_block.final_stack_elements = copy(self._second_block.final_stack_elements) # Update the "comes from" information from the successors of the first block if jumps_to_id is not None: diff --git a/src/cfg_methods/variable_renaming.py b/src/cfg_methods/variable_renaming.py index 0e9e044a..f8274f16 100644 --- a/src/cfg_methods/variable_renaming.py +++ b/src/cfg_methods/variable_renaming.py @@ -70,7 +70,6 @@ def rename_block_list(block_list: CFGBlockList, renaming_dict: Dict[var_id_T, va if block.get_condition() is not None: new_cond_list = rename_var_list([block.get_condition()], renaming_dict) block.set_condition(new_cond_list[0]) - block.final_stack_elements = rename_var_list(block.final_stack_elements, renaming_dict) def rename_vars_in_instr(instruction: CFGInstruction, renaming_dict: Dict[var_id_T, var_id_T]) -> None: diff --git a/src/parser/cfg_block.py b/src/parser/cfg_block.py index 7d930dae..70d1b77f 100644 --- a/src/parser/cfg_block.py +++ b/src/parser/cfg_block.py @@ -105,11 +105,7 @@ def final_stack_elements(self) -> List[str]: Stack elements that must be placed in a specific order in the stack after performing the operations in the block. It can be either the condition of a JUMPI or when invoking a function just after a sub block """ - return self._final_stack_elements - - @final_stack_elements.setter - def final_stack_elements(self, value: List[str]): - self._final_stack_elements = value + return self._split_instruction.get_out_args() if self._split_instruction is not None else [] @property def split_instruction(self) -> Optional[CFGInstruction]: diff --git a/src/parser/optimizable_block_list.py b/src/parser/optimizable_block_list.py index 9f760cb0..de626be8 100644 --- a/src/parser/optimizable_block_list.py +++ b/src/parser/optimizable_block_list.py @@ -61,8 +61,7 @@ def initialize_sub_blocks(initial_block: CFGBlock, sub_blocks_instrs: List[Tuple cfg_sub_block.set_falls_to(current_falls_to) cfg_sub_block.set_jump_to(current_jumps_to) - cfg_sub_block.final_stack_elements = current_stack_values - + current_falls_to = cfg_sub_block.block_id current_jumps_to = None