Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion vyper/venom/basicblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,10 @@ def copy(self) -> IRBasicBlock:
def __repr__(self) -> str:
printer = ir_printer.get()

s = f"{repr(self.label)}: ; OUT={[bb.label for bb in self.out_bbs]}\n"
s = f"{repr(self.label)}:"
if self.is_terminated:
s += f" ; OUT={[bb.label for bb in self.out_bbs]}"
s += "\n"
if printer and hasattr(printer, "_pre_block"):
s += printer._pre_block(self)
for inst in self.instructions:
Expand Down
4 changes: 4 additions & 0 deletions vyper/venom/passes/function_inliner.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ def _inline_call_site(self, func: IRFunction, call_site: IRInstruction) -> None:
if len(inst.operands) > 1:
# sanity check (should remove once new callconv stabilizes)
assert ENABLE_NEW_CALL_CONV
# only handle 1 output from invoke.. the other
# is the return pc. if there are more in the future,
# we need to loop, 1 store for every output.
assert len(inst.operands) == 2, inst
ret_value = inst.operands[0]
bb.insert_instruction(
IRInstruction("store", [ret_value], call_site.output), -1
Expand Down
2 changes: 1 addition & 1 deletion vyper/venom/passes/machinery/inst_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def update(
if isinstance(op, IRVariable):
self.dfg.add_use(op, inst)

if opcode in NO_OUTPUT_INSTRUCTIONS:
if opcode in NO_OUTPUT_INSTRUCTIONS and opcode != "invoke":
if inst.output is not None:
assert new_output is None
assert len(uses := self.dfg.get_uses(inst.output)) == 0, (inst, uses)
Expand Down
10 changes: 7 additions & 3 deletions vyper/venom/venom_to_assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ def generate_evm(self, no_optimize: bool = False) -> list[str]:

for ctx in self.ctxs:
for fn in ctx.functions.values():
print(fn)
ac = IRAnalysesCache(fn)

NormalizationPass(ac, fn).run_pass()
Expand Down Expand Up @@ -283,20 +284,22 @@ def _emit_input_operands(
seen.add(op)

def _prepare_stack_for_function(self, asm, fn: IRFunction, stack: StackModel):
last_param = None
params = []
for inst in fn.entry.instructions:
if inst.opcode != "param":
# note: always well defined if the bb is terminated
next_liveness = self.liveness.live_vars_at(inst)
break

last_param = inst
params.append(inst)

assert inst.output is not None # help mypy
stack.push(inst.output)

# find live params
live_params = [param for param in params if param in next_liveness]
# no params (only applies for global entry function)
if last_param is None:
if len(live_params) == 0:
return

to_pop: list[IRVariable] = []
Expand All @@ -307,6 +310,7 @@ def _prepare_stack_for_function(self, asm, fn: IRFunction, stack: StackModel):

self.popmany(asm, to_pop, stack)

last_param = live_params[-1]
self._optimistic_swap(asm, last_param, next_liveness, stack)

def popmany(self, asm, to_pop: Iterable[IRVariable], stack):
Expand Down
Loading