From febd073b4087020de48faf8d8cb316621648f87b Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Fri, 1 Dec 2023 09:18:24 -0800 Subject: [PATCH] add some comments --- vyper/venom/function.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/vyper/venom/function.py b/vyper/venom/function.py index ef4c98ca5f..c14ad77345 100644 --- a/vyper/venom/function.py +++ b/vyper/venom/function.py @@ -118,7 +118,12 @@ def append_data(self, opcode: str, args: list[IROperand]) -> None: @property def normalized(self) -> bool: """ - Check if function is normalized. + Check if function is normalized. A function is normalized if in the + CFG, no basic block simultaneously has multiple inputs and outputs. + That is, a basic block can be jumped to *from* multiple blocks, or it + can jump *to* multiple blocks, but it cannot simultaneously do both. + Having a normalized CFG makes calculation of stack layout easier when + emitting assembly. """ for bb in self.basic_blocks: # Ignore if there are no multiple predecessors @@ -127,6 +132,12 @@ def normalized(self) -> bool: # Check if there is a conditional jump at the end # of one of the predecessors + # + # TODO: this check could be: + # `if len(in_bb.cfg_out) > 1: return False` + # but the cfg is currently not calculated "correctly" for + # certain special instructions (deploy instruction and + # selector table indirect jumps). for in_bb in bb.cfg_in: jump_inst = in_bb.instructions[-1] if jump_inst.opcode != "jnz":