Skip to content

ABI0 wrapper CALL lowering ignores outgoing SP arguments #44

Description

@cpunion

Discovered while validating xgo-dev/llgo#2691 and draft PR #43.

The generated modernc.org/libc ABI0 wrapper writes outgoing arguments to SP offsets, then calls a Go implementation:

TEXT ·Y__builtin_mul_overflowUint128(SB),$56-52
MOVQ a_Lo+8(FP), AX
MOVQ AX, 8(SP)
MOVQ a_Hi+16(FP), AX
MOVQ AX, 16(SP)
CALL ·X__builtin_mul_overflowUint128(SB)

The amd64 lowering currently initializes SP to zero unless GOARCH=386 and callSym assembles arguments from simulated registers rather than SP memory. Thus accepting the struct signature only produces LLVM IR; it does not preserve the ABI0 call. The real abi0_linux_amd64.s has 1,875 wrappers, 37 of which also use callback trampolines. Translation must model the outgoing SP frame and callback cases before this library can be considered supported. A run test should verify values arrive in X, not just that the LLVM module verifies.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions