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

optimizer fixes and guardrails #2914

Merged
merged 35 commits into from
Jun 21, 2022

Conversation

charles-cooper
Copy link
Member

@charles-cooper charles-cooper commented Jun 16, 2022

What I did

How I did it

How to verify it

Commit message

chore: refactor and improve optimizer

this commit factors out and generalizes the optimizer logic for
comparison operators. it clarifies the logic for dealing with boundary
cases, and cleans up the control flow in the optimizer in general. it
also adds an assembly peephole optimization to help optimize the
assembly generated by the comparator pass.

this commit also introduces a new IR keyword, "unique_symbol". it
functions as a guardrail to help ensure optimizer passes are sane. it is
a statement that codegen can insert into the IR, and sanity checks will
be performed to make sure that the statement is not optimized out, and
in some cases, to ensure that the statement shows up in the optimized
IR. it can be thought of as a very primitive effects tracking framework.

lastly, some tests are added to increase optimizer coverage. 

Description for the changelog

Cute Animal Picture

image

@codecov-commenter
Copy link

codecov-commenter commented Jun 16, 2022

Codecov Report

Merging #2914 (4d9e8bb) into master (4e38ec4) will decrease coverage by 0.42%.
The diff coverage is 95.37%.

@@            Coverage Diff             @@
##           master    #2914      +/-   ##
==========================================
- Coverage   88.47%   88.05%   -0.43%     
==========================================
  Files          97       97              
  Lines       10613    10899     +286     
  Branches     2527     2637     +110     
==========================================
+ Hits         9390     9597     +207     
- Misses        770      836      +66     
- Partials      453      466      +13     
Impacted Files Coverage Δ
vyper/ir/compile_ir.py 93.43% <72.72%> (-0.26%) ⬇️
vyper/codegen/core.py 84.93% <83.33%> (+0.34%) ⬆️
vyper/ir/optimizer.py 95.01% <96.49%> (+2.78%) ⬆️
vyper/builtin_functions/functions.py 92.40% <100.00%> (-1.73%) ⬇️
vyper/codegen/external_call.py 97.34% <100.00%> (+0.02%) ⬆️
vyper/codegen/ir_node.py 92.28% <100.00%> (+1.23%) ⬆️
vyper/codegen/self_call.py 95.65% <100.00%> (+0.19%) ⬆️
vyper/compiler/__init__.py 88.09% <100.00%> (+0.91%) ⬆️
vyper/compiler/output.py 93.78% <100.00%> (ø)
vyper/codegen/function_definitions/utils.py 80.00% <0.00%> (-20.00%) ⬇️
... and 12 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4e38ec4...4d9e8bb. Read the comment docs.

@lgtm-com
Copy link
Contributor

lgtm-com bot commented Jun 18, 2022

This pull request introduces 1 alert when merging c148926 into 4e38ec4 - view on LGTM.com

new alerts:

  • 1 for Unused local variable

there might be true dead code, so only run the exactly-once symbol
checker on binop optimizations.
@lgtm-com
Copy link
Contributor

lgtm-com bot commented Jun 18, 2022

This pull request introduces 1 alert when merging c057cb6 into 4e38ec4 - view on LGTM.com

new alerts:

  • 1 for Unused local variable

@charles-cooper charles-cooper marked this pull request as ready for review June 20, 2022 01:27
@charles-cooper charles-cooper merged commit 2fddbde into vyperlang:master Jun 21, 2022
@charles-cooper charles-cooper deleted the optimizer_fixes branch June 21, 2022 14:04
@emc415 emc415 mentioned this pull request Dec 19, 2022
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