Skip to content

loongarch64: failed to perform tail call elimination on a call site marked musttail #168152

@folkertdev

Description

@folkertdev

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) #1

Errors 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

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions