Skip to content

struct {__float128} should be passed in registers on X86-64  #74601

@jeanPerier

Description

@jeanPerier

I am working on flang, and we have to deal with struct passing ABI in the context of C/Fortran interoperability.
I noticed that struct {__float128} are passed on the stack (byval) by clang on X86-64. Reading at the ABI, I would expect them to be passed in SSE register.

typedef struct {
 __float128 x;
} S;

void bar(__float128 x);

void test(S x) {
    bar(x.x);
}

LLVM IR for X86-64:

define dso_local void @test(ptr noundef byval(%struct.S) align 16 %0)  {
  %2 = getelementptr inbounds %struct.S, ptr %0, i32 0, i32 0
  %3 = load fp128, ptr %2, align 16
  call void @bar(fp128 noundef %3)
  ret void
}
declare void @bar(fp128 noundef)

clang -O3 Assembly:

test:                                   # @test
        movaps  xmm0, xmmword ptr [rsp + 8]
        jmp     bar@PLT    

For info, gcc -O3 / icc -O3 assembly looks like:

test:
        jmp     bar

Metadata

Metadata

Assignees

No one assigned

    Labels

    ABIApplication Binary Interfacebackend:X86

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions