Skip to content

Tails calls are not being emitted as such #45499

Open
@jrmuizel

Description

@jrmuizel

The following rust code should get tail calls:

pub fn moo() -> String {
    goo()
}

#[inline(never)]
pub fn goo() -> String {
    "https://".to_string()
}

Instead we get:

example::moo:
        push    rbp
        mov     rbp, rsp
        push    rbx
        push    rax
        mov     rbx, rdi
        call    example::goo@PLT
        mov     rax, rbx
        add     rsp, 8
        pop     rbx
        pop     rbp
        ret

example::goo:
        push    rbp
        mov     rbp, rsp
        push    rbx
        push    rax
        mov     rbx, rdi
        lea     rsi, [rip + str.0]
        mov     edx, 8
        call    <alloc::string::String as core::convert::From<&'a str>>::from@PLT
        mov     rax, rbx
        add     rsp, 8
        pop     rbx
        pop     rbp
        ret

str.0:
        .ascii  "https://"

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions