pharo-project / pharo-vm

This is the VM used by Pharo
http://pharo.org
Other
113 stars 68 forks source link

Fix a lot of unused expression #832

Closed RenaudFondeur closed 1 month ago

RenaudFondeur commented 2 months ago

add a visitor in Slang to suppress unused expressions after inlining occurs

PalumboN commented 2 months ago

Hi @RenaudFondeur !

I cannot review this PR because all the files were changed by Tonel :(

I was checking the new tests, they looks ok.

suppress unused expression including some more complex than just variables and constants.

Which ones? Those tests show that after inlining there are still some unused local assignments and unnecessary ifs.

RenaudFondeur commented 2 months ago

hello @PalumboN !

The tests missing are the cases where the variable need to be retained because the method to be inlined is either in a return, an assignment or the receiver/argument of a send.

Sometimes inlining doesn't put a goTo node in the conditional send meaning it can become empty during the check, in this case the check either suppress it or reduce it (for example ifTrue:ifFalse: -> ifFalse: if the ifTrue: is empty).

The unused variable can also arrive in the check after getting some transformation like a cast or becoming a function call if it is an instance variable.