Skip to content

Commit

Permalink
Compute final stack elements from the split instruction
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcere committed Nov 20, 2024
1 parent ebbec6a commit 2565049
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/cfg_methods/cfg_block_actions/merge_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion src/cfg_methods/variable_renaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 1 addition & 5 deletions src/parser/cfg_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down
3 changes: 1 addition & 2 deletions src/parser/optimizable_block_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 2565049

Please sign in to comment.