4 ms·
> Curious fact: the above code generates >40000 lines of assembly in godbolt: https://www.godbolt.org/z/fxfbb9jfn https://www.godbolt.org/z/fxfbb9jfn I took a
by messe 5y ago
> Curious fact: the above code generates >40000 lines of assembly in godbolt: https://www.godbolt.org/z/fxfbb9jfn https://www.godbolt.org/z/fxfbb9jfn
I took a quick glance at the ASM, and it seems that the majority of that is code from the stdlib run prior to main. Compiling with -OReleaseSafe brings that down to 15,000 lines of assembly.
If you get rid of "main" and compile it as an exported function, you get far less code: https://www.godbolt.org/z/jjGP4xsfx https://www.godbolt.org/z/jjGP4xsfx
If you add -OReleaseSafe to the "export fn" version I shared, it's around 4 lines of code calling panic. Adding -OReleaseFast, and it's just a ret statement.
- meepmorp 5y ago> Compiling with -OReleaseSafe brings that down to 15,000 lines of assembly. I tried it with -OReleaseFast to compare, and it's 500-ish lines. That's amazing.