Skip to content
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

feat[venom]: store expansion pass #4068

Merged
merged 32 commits into from
Oct 4, 2024

Conversation

charles-cooper
Copy link
Member

@charles-cooper charles-cooper commented May 31, 2024

What I did

How I did it

How to verify it

Commit message

expand `extract_literals` pass (introduced in bb9129aaa42b2f810f) to
also extract variables and rename it to `store_expansion`, allowing for
the dft pass to reorder variable uses more effectively.

since this also gives us the guarantee that each variable is used
exactly once (besides by store instructions), this allows us to make
some simplifications in `venom_to_assembly.py`, since we no longer need
to account for the same variable occurring on the stack more than one
time (cf. for example 5d8280feec16f86ae).

this results in a stack scheduler improvement. for example:
- examples/tokens/ERC20.vy has a 20 byte codesize improvement
- examples/auctions/blind_auction.vy has a 145 byte codesize improvement
- examples/voting/ballot.vy has a 28 byte codesize improvement

across a range of contracts, the improvement seems to be between 1-2%,
but sometimes as high as 5%

since stack operands are now guaranteed to be unique, the old rule to
avoid swapping if two stack operands are the same no longer works. to
address this, this commit adds an equivalence analysis. this creates
equivalence sets of equivalent variables based on store chains, and
then generalizes the rule from "don't swap if two stack operands are
the same" to "don't swap if two stack operands are equivalent".

Description for the changelog

Cute Animal Picture

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

extract IRLiterals which are instruction arguments; this reduces
pressure on the stack scheduler
vyper/venom/passes/extract_literals.py Fixed Show fixed Hide fixed
vyper/venom/passes/store_expansion.py Fixed Show fixed Hide fixed
vyper/venom/passes/store_expansion.py Fixed Show fixed Hide fixed
Copy link

codecov bot commented May 31, 2024

Codecov Report

Attention: Patch coverage is 15.38462% with 66 lines in your changes missing coverage. Please review.

Project coverage is 46.07%. Comparing base (c7669bd) to head (dc8c554).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
vyper/venom/venom_to_assembly.py 4.44% 42 Missing and 1 partial ⚠️
vyper/venom/analysis/equivalent_vars.py 25.00% 18 Missing ⚠️
vyper/venom/passes/store_expansion.py 40.00% 3 Missing ⚠️
vyper/venom/__init__.py 50.00% 1 Missing ⚠️
vyper/venom/stack_model.py 50.00% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (c7669bd) and HEAD (dc8c554). Click for more details.

HEAD has 138 uploads less than BASE
Flag BASE (c7669bd) HEAD (dc8c554)
139 1
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #4068       +/-   ##
===========================================
- Coverage   91.36%   46.07%   -45.29%     
===========================================
  Files         108      109        +1     
  Lines       15662    15691       +29     
  Branches     3446     3449        +3     
===========================================
- Hits        14309     7230     -7079     
- Misses        922     7906     +6984     
- Partials      431      555      +124     

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

@charles-cooper charles-cooper changed the title feat: store expansion pass feat[venom]: store expansion pass Sep 25, 2024
@charles-cooper charles-cooper marked this pull request as ready for review September 25, 2024 15:11
@charles-cooper
Copy link
Member Author

also incidentally fixes #4215

@charles-cooper charles-cooper enabled auto-merge (squash) October 4, 2024 21:36
@charles-cooper charles-cooper merged commit 0e29db0 into vyperlang:master Oct 4, 2024
157 checks passed
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.

2 participants