You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
intbar(int);
intfoo_tail(int x)
{
// Correct, compiles to a single jmp:returnbar(x);
}
intfoo_musttail(int x)
{
// Buggy, loads and re-spills all parameters:__attribute__((musttail)) returnbar(x);
}
intbar(int);
intfoo_tail(int x)
{
// Correct, compiles to a single jmp:returnbar(x);
}
intfoo_musttail(int x)
{
// Buggy, loads and re-spills all parameters:__attribute__((musttail)) returnbar(x);
}
Actually, this isn't a 32-bit issue, it's just easier to trigger with fewer parameters there. Here's the same thing on 64-bit: https://godbolt.org/z/1cao7Gxhv
Turns out musttail just doesn't optimize sibling calls. Patch incoming.
I am getting this, or a closely related issue in c++ land and a member-pointer sibling call which does not consistently
result in a tail-call, without a diagnostic at that
(LadybirdBrowser/ladybird#5641 or the thread here on the ladybird discord as a reference)
I was not yet able to make a minimal reproducer,
but I can confirm that the linked patch does not suffice
Activity
llvmbot commentedon Jul 10, 2025
@llvm/issue-subscribers-backend-x86
Author: Brandt Bucher (brandtbucher)
Details
For example, this code:Compiles to:
Compiler Explorer
Adding more parameters to the function (and tail call) increases the number of redundant loads/spills, too.
[-]`musttail` generates redundant moves on 32-bit platforms[/-][+]`musttail` doesn't optimize sibling calls[/+]brandtbucher commentedon Jul 22, 2025
Actually, this isn't a 32-bit issue, it's just easier to trigger with fewer parameters there. Here's the same thing on 64-bit: https://godbolt.org/z/1cao7Gxhv
Turns out
musttailjust doesn't optimize sibling calls. Patch incoming.Hendiadyoin1 commentedon Jul 31, 2025
I am getting this, or a closely related issue in c++ land and a member-pointer sibling call which does not consistently
result in a tail-call, without a diagnostic at that
(LadybirdBrowser/ladybird#5641 or the thread here on the ladybird discord as a reference)
I was not yet able to make a minimal reproducer,
but I can confirm that the linked patch does not suffice
brandtbucher commentedon Jul 31, 2025
Is your issue that tail-calls aren't being emitted at all? That seems like something separate.
This is just a code quality issue, not a correctness one.
Hendiadyoin1 commentedon Jul 31, 2025
ah, yeah it fully fails to tail-call in some cases, seems like I misread the issue (multiple times)
x86: fix musttail sibcall miscompilation (llvm#168956)
Automerge: x86: fix musttail sibcall miscompilation (#168956)
x86: fix musttail sibcall miscompilation (llvm#168956)
Automerge: x86: fix musttail sibcall miscompilation (#168956)
x86: fix musttail sibcall miscompilation (#168956)
x86: fix musttail sibcall miscompilation (#168956)
x86: fix musttail sibcall miscompilation (#168956)