[clang] [clang] Always pass fp128 arguments indirectly on Windows (PR #115052)

Trevor Gross via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 5 12:19:25 PST 2024


tgross35 wrote:

It seems like arguments aren't actually getting passed indirectly to libcalls. Simple test program

```c
#include <stdint.h>
#include <stdio.h>

union ty128 {
  struct { uint64_t hi, lo; } u64x2;
  __float128 f128;
};

void f128_add(__float128 a, __float128 b) {
    union ty128 cvt;
    cvt.f128 = a * b;
    printf("0x%016llx%016llx\n", cvt.u64x2.lo, cvt.u64x2.hi);
}

int main() {
    __float128 fa, fb;

    fa = 122134.345678901234;
    fb = 78.9012345678901234;

    f128_add(fa, fb);
}
```

Checking right before the call to `__multf3`.  Built with GCC `rcx` points to a return slot on the stack, `rdx` and `r8` point to the two float values (0x400f... and 0x4005...):

```text
(gdb) x/2gx $rcx
0x7ffffcb30:    0x00000007ffffcbf0      0x00000007ffffcc85
(gdb) x/2gx $rdx
0x7ffffcb20:    0xb000000000000000      0x400fdd16587e6997
(gdb) x/2gx $r8
0x7ffffcb10:    0x8000000000000000      0x40053b9add3c0c73
```

Built using this patch, it looks like Clang is putting the float arguments in `$rcx` and `$rdx` and not leaving a return slot pointer:

```text
(gdb) x/2gx $rcx
0x5ffe70:       0xb000000000000000      0x400fdd16587e6997
(gdb) x/2gx $rdx
0x5ffe60:       0x8000000000000000      0x40053b9add3c0c73
(gdb) x/2gx $r8
0x622720:       0x0000000000622988      0x00000000006229a7
```

Is libcall ABI handled elsewhere?

https://github.com/llvm/llvm-project/pull/115052


More information about the cfe-commits mailing list