News for hackers. Stuff that matters.
Re:ABI Mistakes by Teknoman117 on Saturday May 08, 2021 @02:15PM (#27089484)
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.
Re:ABI Mistakes by mhh__ on Saturday May 08, 2021 @02:26PM (#27089565)
Why is that not the case with any other language and LTO?
Re:ABI Mistakes by comex on Saturday May 08, 2021 @04:50PM (#27090567)
It 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.

Re:ABI Mistakes by pjmlp on Sunday May 09, 2021 @10:25AM (#27096133)
Besides 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.

Re:ABI Mistakes by donkarma on Saturday May 08, 2021 @03:56PM (#27090158)
I 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.