Skip to content

refactor[venom]: extract liveness and cfg data structures #4595

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

Merged

Conversation

charles-cooper
Copy link
Member

@charles-cooper charles-cooper commented Apr 24, 2025

What I did

How I did it

How to verify it

Commit message

this commit removes the data structures related to liveness and
the CFG from venom instructions/basic blocks. this makes it so that
the lifetime of the data structures is tied to the lifetime of the
analyses, rather than needing to invalidate on the instructions/basic
blocks, making them more "pure".

it also starts a pattern of deleting attributes from analyses at
invalidation, making it so that if we accidentally try to access
analyses that have been invalidated, an ugly `AttributeError` is
thrown.

misc/refactor:
- clean up some type signatures

Description for the changelog

Cute Animal Picture

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

@charles-cooper charles-cooper marked this pull request as ready for review April 24, 2025 13:33
@charles-cooper charles-cooper requested review from harkal and HodanPlodky and removed request for harkal April 24, 2025 13:33
Copy link

codecov bot commented Apr 25, 2025

Codecov Report

Attention: Patch coverage is 95.78544% with 11 lines in your changes missing coverage. Please review.

Project coverage is 92.43%. Comparing base (5fe3d2e) to head (4f12bdd).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
vyper/venom/function.py 62.50% 2 Missing and 1 partial ⚠️
vyper/venom/passes/simplify_cfg.py 94.33% 1 Missing and 2 partials ⚠️
vyper/venom/analysis/analysis.py 83.33% 1 Missing and 1 partial ⚠️
vyper/venom/analysis/liveness.py 94.28% 1 Missing and 1 partial ⚠️
vyper/venom/analysis/mem_ssa.py 92.85% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4595      +/-   ##
==========================================
- Coverage   92.43%   92.43%   -0.01%     
==========================================
  Files         127      127              
  Lines       18327    18353      +26     
  Branches     3179     3178       -1     
==========================================
+ Hits        16941    16965      +24     
  Misses        947      947              
- Partials      439      441       +2     

☔ 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.

@@ -3,19 +3,28 @@
from vyper.exceptions import CompilerPanic
from vyper.utils import OrderedSet
from vyper.venom.analysis import CFGAnalysis, IRAnalysis
from vyper.venom.basicblock import IRBasicBlock, IRVariable
from vyper.venom.basicblock import IRBasicBlock, IRInstruction, IRVariable


class LivenessAnalysis(IRAnalysis):
"""
Compute liveness information for each instruction in the function.
"""

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
cfg: CFGAnalysis

Copy link
Collaborator

Choose a reason for hiding this comment

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

I more similar things should I create a PR for that quickly

Copy link
Member Author

Choose a reason for hiding this comment

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

sure


from vyper.codegen.ir_node import IRnode
from vyper.venom.basicblock import IRBasicBlock, IRLabel, IRVariable

if TYPE_CHECKING:
from vyper.venom.context import IRContext

Check failure

Code scanning / CodeQL

Module-level cyclic import Error

'IRContext' may not be defined if module
vyper.venom.context
is imported before module
vyper.venom.function
, as the
definition
of IRContext occurs after the cyclic
import
of vyper.venom.function.
'IRContext' may not be defined if module
vyper.venom.context
is imported before module
vyper.venom.function
, as the
definition
of IRContext occurs after the cyclic
import
of vyper.venom.function.
@charles-cooper charles-cooper merged commit 642da76 into vyperlang:master Apr 27, 2025
161 of 162 checks passed
@charles-cooper charles-cooper deleted the refactor/venom/liveness-and-cfg branch April 27, 2025 14:05
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