[clang] [llvm] [LLVMAABI][AARCH64] Handle homogeneous aggregate return types (PR #218799)

Madhur Amilkanthwar via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 3 21:55:27 PDT 2026


================
@@ -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));
----------------
madhur13490 wrote:

This can be simplified to Width = llvm::bit_ceil(Width).

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


More information about the cfe-commits mailing list