Open cypheon opened 1 month ago
@llvm/issue-subscribers-backend-x86
Author: Johann Rudloff (cypheon)
I was able to narrow this down to the interaction of the "shrink-wrap" optimisation combined with musttail tail calls.
Passing --enable-shrink-wrap=false
to llc
results in correctly compiled code.
In some cases, when calling a tailcc function in tail position,
rsp
is increased in a branch where it has never been decreased. This leads to corrupted stack pointer (and probably a segfault) in the following function.Repro:
Resulting assembly:
https://godbolt.org/z/ze7r8j67o
As far as I can see, the issue does not occur on aarch64. There the stack pointer is decremented right at the beginning (before the branch), so the increment before the tail call is correct.