[clang] [CIR] Add calling convention lowering for mfloat8 types (PR #246165)

Adam Smith via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 1 09:53:46 PST 2026


================
@@ -141,6 +137,8 @@ static bool isSupportedType(mlir::Type ty, const DataLayout &dl) {
   }
   if (isa<cir::VoidType, cir::BoolType>(ty))
     return true;
+  if (isa<cir::MFloat8Type>(ty))
+    return true;
----------------
adams381 wrote:

This also makes `va_arg(ap, __mfp8)` reachable on AArch64, and it reads the wrong save area.  `CIRABIRewriteContextAArch64.cpp` picks the register class with `mlir::isa<cir::FPTypeInterface, cir::VectorType>(baseTy)`, and `cir::MFloat8Type` is neither, so the value is fetched from `__gr_offs` and `__gr_top`.  Classic codegen decides from `ConvertType`, which gives `<1 x i8>`, so it uses `__vr_offs` and `__vr_top`.  The caller passes the value as `<1 x i8>` on both paths, so it arrives in a SIMD register.  Before this change the type was rejected as NYI, so this turns an error into a silently wrong value.

```c
#include <stdarg.h>

__mfp8 get_mfp8(int n, ...) {
  va_list ap;
  va_start(ap, n);
  __mfp8 v = va_arg(ap, __mfp8);
  va_end(ap);
  return v;
}
```

With `-triple aarch64-none-linux-gnu -target-feature +neon -fclangir -emit-llvm`, the CIR path loads `%struct.__va_list` fields 3 and 1, where classic codegen loads fields 4 and 2.  Adding `cir::MFloat8Type` to that `isa` looks like the fix, along with a `va_arg` case in `aarch64-mfp8.c`.


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


More information about the cfe-commits mailing list