vyperlang / vyper

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

feat[venom]: optimize mem2var and store/variable elimination pass sequences #4032

Closed harkal closed 4 months ago

harkal commented 4 months ago

What I did

Apply mem2var pass after we are in SSA form -as appropriate-, and add an additional store elimination pass after SCCP. Improves code size a bit.

How I did it

How to verify it

Commit message

The `Mem2Var` pass needs to operate on SSA form. This commit 
updates the order of passes to accommodate for this. Additionally
we add an extra `StoreElimination` pass after `SCCP` to further
reduce the generated code size.

Additionally, it updates the `RemoveUnusedVariablesPass` to eliminate
all unused variables without the need to be run multiple times.

Description for the changelog

Cute Animal Picture

![Put a link to a cute animal picture inside the parenthesis-->]()

charles-cooper commented 4 months ago

this seems fine. should we also add back in the loop for remove_unused_variables?

charles-cooper commented 4 months ago

i think we call the store elimination pass too many times now -- i get identical bytecode across a range of contracts after removing the first store elimination pass

harkal commented 4 months ago

i think we call the store elimination pass too many times now -- i get identical bytecode across a range of contracts after removing the first store elimination pass

I updated the pass to not require multiple calls!