[clang] [MIPS] fix zero-sized type causing incorrect register for later float arguments (PR #213746)

via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 5 20:10:52 PDT 2026


================
@@ -28,3 +28,40 @@ T2 T2_retval;
 T2 fn28(char arg0) {
   return T2_retval;
 }
+
+// A zero-sized argument consumes no register, but on O32 it does end the run of
+// leading floating-point arguments, so the arguments after it are passed in
+// integer registers.
+//
+// O32: define{{.*}} void @fn29(i32 noundef %arg1.coerce, i64 noundef %arg2.coerce)
+// O32: declare void @fn30(i32 noundef, i64 noundef)
----------------
yingopq wrote:

I tested two different scenarios with gcc, both using integer registers.
```
struct E {};
void f(float x, struct E a0, float y);
void caller(void) {
    struct E e;
    f(1.5f, e, 2.0f);
}

        addiu   $sp,$sp,-32
        sw      $31,28($sp)
        sw      $fp,24($sp)
        move    $fp,$sp
        lui     $2,%hi($LC0)
        lw      $3,%lo($LC0)($2)
        lui     $2,%hi($LC1)
        lw      $2,%lo($LC1)($2)
        move    $5,$3
        move    $4,$2
        jal     f
        nop

        nop
        move    $sp,$fp
        lw      $31,28($sp)
        lw      $fp,24($sp)
        addiu   $sp,$sp,32
        jr      $31
        nop

```
and
```
struct E {};
void f(float x, float y, struct E a0);
void caller(void) {
    struct E e;
    f(1.5f, 2.0f, e);
}

        addiu   $sp,$sp,-32
        sw      $31,28($sp)
        sw      $fp,24($sp)
        move    $fp,$sp
        lui     $2,%hi($LC0)
        lw      $3,%lo($LC0)($2)
        lui     $2,%hi($LC1)
        lw      $2,%lo($LC1)($2)
        move    $5,$3
        move    $4,$2
        jal     f
        nop

        nop
        move    $sp,$fp
        lw      $31,28($sp)
        lw      $fp,24($sp)
        addiu   $sp,$sp,32
        jr      $31
        nop
```

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


More information about the cfe-commits mailing list