Skip to content

Conversation

@harkal
Copy link
Collaborator

@harkal harkal commented Sep 10, 2025

What I did

Extent Venom to support multi-output instructions and implemented a multi-output invoke for functions that return multiple values.

How I did it

How to verify it

Commit message

Implements support for instructions with multiple return values, primarily for
the `invoke` instruction using stack-based return convention. Instructions can
now have multiple outputs via `_outputs` field, with `get_outputs()` and other
helpers.

Key changes:
  - Add `_outputs` field to IRInstruction for multi-output support
  - Fix parser, DFG analysis, and optimisation passes to handle multi-output
  - Update venom-to-assembly to properly manage stack for multi-return invoke
  - Add comprehensive tests for multi-output invoke instructions

Description for the changelog

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

@codecov
Copy link

codecov bot commented Sep 18, 2025

Codecov Report

❌ Patch coverage is 90.83095% with 32 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.23%. Comparing base (a68eb57) to head (fbd7108).

Files with missing lines Patch % Lines
vyper/venom/check_venom.py 88.31% 8 Missing and 1 partial ⚠️
vyper/venom/basicblock.py 89.18% 4 Missing ⚠️
vyper/venom/ir_node_to_venom.py 94.28% 3 Missing and 1 partial ⚠️
vyper/venom/passes/dft.py 63.63% 2 Missing and 2 partials ⚠️
vyper/venom/function.py 0.00% 3 Missing ⚠️
vyper/venom/venom_to_assembly.py 90.00% 1 Missing and 2 partials ⚠️
vyper/venom/parser.py 90.47% 1 Missing and 1 partial ⚠️
...r/venom/passes/common_subexpression_elimination.py 50.00% 1 Missing and 1 partial ⚠️
vyper/venom/analysis/dfg.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4747      +/-   ##
==========================================
- Coverage   93.27%   93.23%   -0.05%     
==========================================
  Files         137      137              
  Lines       19455    19616     +161     
  Branches     3361     3399      +38     
==========================================
+ Hits        18146    18288     +142     
- Misses        888      903      +15     
- Partials      421      425       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.


inst = IRInstruction("invoke", inst_args, ret)
inst = IRInstruction("invoke", inst_args, single_output)
if extra_outputs:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check is not None

Copy link
Member

@charles-cooper charles-cooper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work.

couple comments about the approach:

@harkal harkal requested a review from charles-cooper October 30, 2025 18:15
Copy link
Collaborator

@HodanPlodky HodanPlodky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose this is expected but just for sake of it not being forgotten, there is a small codesize regression in cases where the return values needs to be stored in memory after the call. Before this PR it could be done in the internal function it self but if the value is returned in stack then it needs to be done after every invoke. But I found at most 8 bytes of difference (in vault). Other than this note, it seems nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants