-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Open
Labels
Description
This LLVM IR
https://godbolt.org/z/8TsGoPvnj
target triple = "loongarch64-unknown-linux-gnu"
define internal void @callee(ptr dead_on_unwind noalias noundef nonnull writable writeonly sret([24 x i8]) align 1 captures(none) dereferenceable(24) initializes((0, 24)) %_0) unnamed_addr {
start:
tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(24) %_0, i8 0, i64 24, i1 false)
ret void
}
define void @dispatch(ptr dead_on_unwind noalias noundef writable writeonly sret([24 x i8]) align 1 captures(none) dereferenceable(24) initializes((0, 24)) %_0) unnamed_addr {
start:
musttail call void @callee(ptr noalias noundef sret([24 x i8]) align 1 captures(none) dereferenceable(24) %_0)
ret void
}
declare void @llvm.memset.p0.i64(ptr writeonly captures(none), i8, i64, i1 immarg) #1Errors with
LLVM ERROR: failed to perform tail call elimination on a call site marked musttail
I suspect riscv has essentially the same problem, see also
- [clang] RISC-V: failed to perform tail call elimination on a call site marked musttail #157814
- riscv64: rustc-LLVM ERROR: failed to perform tail call elimination on a call site marked musttail rust-lang/rust#148748
This is inconvenient for rust stabilization of guaranteed tail calls. For rust it would be sufficient to accept the case where the stack space used for the return value is identical for callee and dispatch, that is probably easier to support than the general case.