[clang] [llvm] [LLVM][ABI][AARCH64] Add support for MSVC homogeneous aggregates (PR #239846)

Madhur Amilkanthwar via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 8 23:32:14 PST 2026


================
@@ -0,0 +1,145 @@
+// RUN: %clang_cc1 -triple aarch64-windows-msvc -std=c++20 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-windows-msvc -std=c++20 -fexperimental-abi-lowering -emit-llvm -o - %s 2>&1 | FileCheck %s --implicit-check-not="not yet implemented"
+
+// Each record holds 16 bytes of doubles. An HFA is passed as [2 x double] and
+// a record that MSVC does not treat as an HFA is passed as [2 x i64].
+
+struct Empty {};
+struct ZeroLength {
+  int arr[0];
+};
+struct DoubleBase {
+  double a;
+};
+
+extern "C" {
+
+struct Pod {
+  double a, b;
+};
+void arg_pod(Pod s) {}
+// CHECK: define{{.*}} void @arg_pod([2 x double] %{{.*}})
+
+struct TrivialCopyAssign {
+  double a, b;
+  TrivialCopyAssign &operator=(const TrivialCopyAssign &) = default;
+};
+void arg_trivial_copy_assign(TrivialCopyAssign s) {}
+// CHECK: define{{.*}} void @arg_trivial_copy_assign([2 x double] %{{.*}})
+
+struct NonTrivialCopyAssign {
+  double a, b;
+  NonTrivialCopyAssign &operator=(const NonTrivialCopyAssign &);
+};
+void arg_non_trivial_copy_assign(NonTrivialCopyAssign s) {}
+// CHECK: define{{.*}} void @arg_non_trivial_copy_assign([2 x i64] %{{.*}})
+
+struct NonDefaultCtor {
+  double a, b;
+  NonDefaultCtor(int);
+};
+void arg_non_default_ctor(NonDefaultCtor s) {}
+// CHECK: define{{.*}} void @arg_non_default_ctor([2 x double] %{{.*}})
+
+struct UserDefaultCtor {
+  double a, b;
+  UserDefaultCtor();
+};
+void arg_user_default_ctor(UserDefaultCtor s) {}
+// CHECK: define{{.*}} void @arg_user_default_ctor([2 x i64] %{{.*}})
+
+struct MemberInit {
+  double a = 1.0;
+  double b;
+};
+void arg_member_init(MemberInit s) {}
+// CHECK: define{{.*}} void @arg_member_init([2 x i64] %{{.*}})
+
+struct TrivialDtor {
+  double a, b;
+  ~TrivialDtor() = default;
+};
+void arg_trivial_dtor(TrivialDtor s) {}
+// CHECK: define{{.*}} void @arg_trivial_dtor([2 x double] %{{.*}})
+
+struct NonTrivialDtor {
+  double a, b;
+  ~NonTrivialDtor();
+};
+void arg_non_trivial_dtor(NonTrivialDtor s) {}
+// CHECK: define{{.*}} void @arg_non_trivial_dtor([2 x i64] %{{.*}})
+
+struct PrivateMember {
+  double a;
+
+private:
+  double b;
+};
+void arg_private_member(PrivateMember s) {}
+// CHECK: define{{.*}} void @arg_private_member([2 x double] %{{.*}})
----------------
madhur13490 wrote:

Could you add a polymorphic case? Nothing in this file currently goes through the `IsPolymorphic` flag, and `convertStructType` now sets it for polymorphic classes without bases, which it did not do before.

```cpp
struct Polymorphic {
  virtual void f();
  double a, b;
};
void arg_polymorphic(Polymorphic s) {}
// CHECK: define{{.*}} void @arg_polymorphic(ptr{{.*}} %{{.*}})
```

Such a class is passed indirectly because its copy constructor is non-trivial, so it never reaches the HFA check. The test still confirms that the experimental path agrees with the classic one and doesn't hit a
"not yet implemented" error. It might also be worth mentioning the `convertStructType` flag change in the description.

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


More information about the cfe-commits mailing list