5 ms·
The other neat thing about Rust is that if you turn on LTO and all of the involved code is Rust, there is no hard ABI. The linker will do all sorts of interesti
by Teknoman117 5y ago
The other neat thing about Rust is that if you turn on LTO and all of the involved code is Rust, there is no hard ABI. The linker will do all sorts of interesting things with register usage and how to pass data to functions.
- mhh__ 5y agoWhy is that not the case with any other language and LTO?
- donkarma 5y agoI think MSVC has some weird things when you call a function and you do this, I don't remember but it had a weird calling convention in the assembly IIRC.
- comex 5y agoIt is. As far as I know, rustc just exposes LLVM’s LTO functionality, without performing any Rust-specific optimizations at link time. So you get the same optimizations as you would with LTO in Clang (C compiler), and indeed you can do cross-language LTO between the two. Also, even without LTO, LLVM can perform the same ABI optimizations on functions that are local to a single translation unit and not exported to other ones. In Rust that means a function not exported across crate boundaries. In C that means a `static` function.
- pjmlp 5y agoBesides the sibling comments, this is already highly exploited in JITs for example. Since only the JIT sees the native code, alongside JIT caches[0] you have basically LTO and PGO data across runs and some call graphs might eventually be collapse into simple basic block, or structs might be reduced to the actual set of fields that are used. [0] - This includes all modern JVM implementations including the Android cousin, and .NET to certain extent already with usability improvements coming in version 6.