vyperlang / vyper

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

feat[venom]: improve unused variable removal pass #4055

Closed harkal closed 1 month ago

harkal commented 1 month ago

What I did

Implemented a better variable elimination pass. This new implementation is efficient and manages to remove all unused variables in one run.

Additionally, this PR adds some extra utility functions to OrderedSet()

How I did it

How to verify it

Commit message

This commit improves the variable elimination pass by efficiently removing 
all instructions that produce unused output. This new algorithm removes all
unused variables in one run.

Additionally, it adds the utility functions `pop()` and `addmany()` to the
`OrderedSet()` class.

The `DFTAnalysis` is also augmented with a method to remove uses:
`remove_use(self, op: IRVariable, inst: IRInstruction)`

Description for the changelog

Cute Animal Picture

                 __
                / _)--< 
       _.----._/ /          
     /          /  Dinosnek          
 __/ (  |  (   |             
/__.-'|_|--|__|