================
@@ -82,3 +89,123 @@ bool TargetInfo::maybeCommonClassifyReturnType(FunctionInfo 
&FI) const {
 
   return false;
 }
+
+namespace {
+
+bool isEmptyRecordForHA(const Type *Ty) {
+  const auto *RT = dyn_cast<RecordType>(Ty);
+  return RT && RT->isEmpty();
+}
+
+/// Storage-container width mirroring Clang's ASTContext::getTypeSize for the
+/// types that matter to homogeneous-aggregate detection.
+uint64_t getHATypeSizeInBits(const Type *Ty) {
+  if (const auto *VT = dyn_cast<VectorType>(Ty)) {
+    uint64_t EltWidth = VT->getElementType()->getSizeInBits().getFixedValue();
+    uint64_t Width = std::max<uint64_t>(
+        8, EltWidth * VT->getNumElements().getKnownMinValue());
+    if (Width & (Width - 1))
+      Width = alignTo(Width, bit_ceil(Width));
+    return Width;
+  }
+  return Ty->getSizeInBits().getFixedValue();
+}
+
+} // namespace
+
+bool TargetInfo::isHomogeneousAggregate(const Type *Ty, const Type *&Base,
+                                        uint64_t &Members) const {
----------------
madhur13490 wrote:

`QualTypeMapper` maps a `ConstantMatrixType` to an `ArrayType` with 
`IsMatrix=true (QualTypeMapper.cpp:105-110)`, and this branch doesn't skip it. 
So `struct { float m __attribute__((matrix_type(2,2))); }` is treated as a 
4-member float `HFA. isAggregateTypeForABI` already special-cases matrices 
(`TargetInfo.cpp:28-30)`; the same guard `(if (AT->isMatrixType()) return 
false;)` is needed here. Classic CodeGen returns that struct as [2 x i64], not 
a direct HFA.

https://github.com/llvm/llvm-project/pull/218799
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to