vyperlang / vyper

Pythonic Smart Contract Language for the EVM
https://vyperlang.org
Other
4.83k stars 789 forks source link

refactor[venom]: introduce `IRContext` and `IRAnalysisCache` #3983

Closed harkal closed 3 months ago

harkal commented 3 months ago

What I did

This PR completes a big refactor of the venom codebase, while introducing IRContext and IRPassManager. IRContext is now encapsulating the whole Venom context of compilation which now contains all the IRFunctions. The pass manager IRPassManages attempts to clean up the pass/analysis handling, by providing a way for passes to request and retrieve specific analyses over the Venom code.

How I did it

How to verify it

Commit message

Add the implementation if `IRContext` and `IRPassManager` along with the required refactoring

Description for the changelog

Cute Animal Picture

841e3b75-4387-48b3-a4cd-174557493b80 copy

harkal commented 3 months ago

question: why do request_analysis and invalidate_analysis have to be called imperatively? is there any way for a pass to register which analyses it needs and then there is automated machinery which calls request_analysis and invalidate_analysis?

I tried both designs, but the imperative won at the end. It's more clear/explicit when and how request and invalidations happen, and it gives you the flexibility of sequencing and re-requesting analyses when needed depending on the nature of the pass.

charles-cooper commented 3 months ago

and it gives you the flexibility of sequencing and re-requesting analyses when needed depending on the nature of the pass.

like here? https://github.com/vyperlang/vyper/pull/3983/files#diff-014351fadf932e6f54253bd6705a6b85dda68db2e9ac7daa6aad133bc2253217R71

charles-cooper commented 3 months ago

note: large contracts i was testing come from 24s to ~6-7s(!)