diff --git a/vyper/venom/function.py b/vyper/venom/function.py index fb0dabc99a..2f2d477460 100644 --- a/vyper/venom/function.py +++ b/vyper/venom/function.py @@ -195,17 +195,19 @@ def chain_basic_blocks(self) -> None: """ bbs = list(self.get_basic_blocks()) for i, bb in enumerate(bbs): - if not bb.is_terminated: - if i < len(bbs) - 1: - # TODO: revisit this. When contructor calls internal functions they - # are linked to the last ctor block. Should separate them before this - # so we don't have to handle this here - if bbs[i + 1].label.value.startswith("internal"): - bb.append_instruction("stop") - else: - bb.append_instruction("jmp", bbs[i + 1].label) + if bb.is_terminated: + continue + + if i < len(bbs) - 1: + # TODO: revisit this. When contructor calls internal functions + # they are linked to the last ctor block. Should separate them + # before this so we don't have to handle this here + if bbs[i + 1].label.value.startswith("internal"): + bb.append_instruction("stop") else: - bb.append_instruction("exit") + bb.append_instruction("jmp", bbs[i + 1].label) + else: + bb.append_instruction("stop") def copy(self): new = IRFunction(self.name) diff --git a/vyper/venom/ir_node_to_venom.py b/vyper/venom/ir_node_to_venom.py index e30f27f480..02a9f4d1f7 100644 --- a/vyper/venom/ir_node_to_venom.py +++ b/vyper/venom/ir_node_to_venom.py @@ -255,6 +255,7 @@ def _convert_ir_bb(fn, ir, symbols): elif ir.value == "deploy": ctx.ctor_mem_size = ir.args[0].value ctx.immutables_len = ir.args[2].value + fn.get_basic_block().append_instruction("exit") return None elif ir.value == "seq": if len(ir.args) == 0: @@ -398,10 +399,7 @@ def _convert_ir_bb(fn, ir, symbols): bb = IRBasicBlock(label, fn) fn.append_basic_block(bb) code = ir.args[2] - if code.value == "pass": - bb.append_instruction("exit") - else: - _convert_ir_bb(fn, code, symbols) + _convert_ir_bb(fn, code, symbols) elif ir.value == "exit_to": args = _convert_ir_bb_list(fn, ir.args[1:], symbols) var_list = args