FuelLabs / sway

🌴 Empowering everyone to build reliable and efficient smart contracts.
https://docs.fuel.network/docs/sway/
Apache License 2.0
62.59k stars 5.37k forks source link

Parent issue for IR optimization passes #2383

Open mohammadfawaz opened 2 years ago

mohammadfawaz commented 2 years ago

This is a parent issue for all the basic optimization passes that we plan on adding. Please feel free to modify this description if you'd like to add more to it or remove some that you don't think are useful.

Also:

otrho commented 2 years ago

Cool. The above list is of optimisation pass categories really, and we can add sublists as we go. E.g., there's already function inlining but it needs improvement as it currently inlines everything -- it needs heuristics to decide what & when to inline. And we already have some constant folding but only for the intialisation of structs -- there are dozens of different areas where constant combining can be added separately.

As we add more passes there will arise the need for a pass manager too, but that can probably go in another issue. I have had a few ideas for making a modern pass manager. Might be worth creating an RFC for.

tritao commented 2 years ago

It might also be useful to take a look at Binaryen's set of optimizations, as well as their implementations, as the code is more self-contained and dependency-free, as compared to LLVM.

otrho commented 2 years ago

Slide 19 in this presentation from Graydon Hoare: http://venge.net/graydon/talks/CompilerTalk-2019.pdf

Frances Allen Got All The Good Ones

mohammadfawaz commented 1 year ago

@vaivaswatha I will keep this issue assigned to you as you own all its subtasks.