Skip to content

fix[venom]: fix inliner return items #4614

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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 @@ -798,7 +798,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
11 changes: 11 additions & 0 deletions vyper/venom/passes/function_inliner.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,17 @@
inst.opcode = "store"
inst.operands = [inst.operands[0]]
elif inst.opcode == "ret":
if call_site.output is not None:
# 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
return_value = inst.operands[0]
set_output_inst = IRInstruction(

Check warning on line 150 in vyper/venom/passes/function_inliner.py

View check run for this annotation

Codecov / codecov/patch

vyper/venom/passes/function_inliner.py#L148-L150

Added lines #L148 - L150 were not covered by tests
"store", [return_value], output=call_site.output
)
call_site_return.insert_instruction(set_output_inst, index=0)

Check warning on line 153 in vyper/venom/passes/function_inliner.py

View check run for this annotation

Codecov / codecov/patch

vyper/venom/passes/function_inliner.py#L153

Added line #L153 was not covered by tests

inst.opcode = "jmp"
inst.operands = [call_site_return.label]

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 @@ -51,7 +51,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