Prevent inline

Does anyone know a trick or official means to prevent a function from being inlined? Any ugly trick would be fine.
6 Replies
Melody Daniel
Melody Daniel7mo ago
Does Mojo inline functions by default? The Mojo compiler has always been taunted as simple because it doesn't do all this compiler magic unless you explicitly tell it to.
Henk-Jan Lebbink
One of the mayor selling point (for me) is that Mojo does the most imaginable optimizations currently available. compiling C++ to MLIR and lowering all the way back to assembly is neat, but the first step C++ to MLIR will loose many intentions a C++ programmer may have had. Mojo is (for me) a nice MLIR syntax. As a result the "compiler magic" is maximal. That also means that almost everything get inlined... which may not be what you need when debugging stuff...
Sardor
Sardor7mo ago
Yes, mojo does .
Normally the compiler will do this automatically where it improves performance, but this decorator forces it to occur, the downside is that it can increase the binary size for the duplicated functions
Normally the compiler will do this automatically where it improves performance, but this decorator forces it to occur, the downside is that it can increase the binary size for the duplicated functions
https://mojodojo.dev/guides/decorators/always_inline.html
@always_inline | Mojo Dojo
Learning Resources for Mojo 🔥
Melody Daniel
Melody Daniel7mo ago
I see. Basically we need a decorator that says "don't inline".
benny
benny7mo ago
you can add -0O (that’s a zero then a capital O) to mojo build to prevent inlining stands for zero optimizations
Melody Daniel
Melody Daniel7mo ago
Ah, nice
Want results from more Discord servers?
Add your server