I fixed x86 tail calls in LLVM
https://github.com/llvm/llvm-project/pull/168956
Tail calls passing structs had been broken since forever, and it made me mad enough to write C++.
It's a little tricky because sometimes it requires shuffling values around on the stack and you have to make sure to not overwrite values you'll need later. This was fixed in the arm backend a while ago, and I was able to port that approach to the x86 backend. The plan is to include this in LLVM 22.
Together with some other changes it seems like guaranteed tail calls in rust might actually, finally happen.
@folkertdev
The guaranteed tail call stuff in Clang has some unfortunate issues with the always-online attribute, where you can write code both the can do tail-call elimination in the back end that the front end will reject and vice versa.
If people are working on this in Rust, I’m curious whether they have a solution to this. Does Rust for forced inlining in the MIR layer? That should make it easier to fix than for Clang.