Skip to content

Regression in LLVM 22: Cannot pass more than 6 arguments in "musttail" tail call on x86-64 #199224

@cypheon

Description

@cypheon

When compiling the following code:

declare tailcc void @f1(i64, i64, i64, i64, i64, i64, i64)

define tailcc void @repro(i64, i64, i64, i64, i64, i64, i64) {
  musttail call tailcc void @f1(i64 1, i64 4, i64 8, i64 15, i64 16, i64 23, i64 42)
  ret void
}

The 7th argument is not passed to function f1:

repro:                                  # @repro
# %bb.0:
        mov     edi, 1
        mov     esi, 4
        mov     edx, 8
        mov     ecx, 15
        mov     r8d, 16
        mov     r9d, 23
        jmp     f1@PLT                          # TAILCALL
                                        # -- End function

See: https://godbolt.org/z/5z98T6fGx

In x86 (32-bit), only one argument is passed correctly, arguments 2-7 are dropped.

In LLVM 21 and before, the same code was compiled correctly:

repro:                                  # @repro
# %bb.0:
        mov     qword ptr [rsp + 8], 42
        mov     edi, 1
        mov     esi, 4
        mov     edx, 8
        mov     ecx, 15
        mov     r8d, 16
        mov     r9d, 23
        jmp     f1@PLT                          # TAILCALL
                                        # -- End function

Metadata

Metadata

Assignees

No one assigned

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions