================
@@ -486,6 +486,39 @@ ABIArgInfo AArch64ABIInfo::classifyArgumentType(QualType 
Ty, bool IsVariadicFn,
     }
     Size = llvm::alignTo(Size, Alignment);
 
+    // If the Aggregate is made up of pointers, use an array of pointers for 
the
+    // coerced type. This prevents having to convert ptr2int->int2ptr through
+    // the call, allowing alias analysis to produce better code.
+    std::function<bool(QualType Ty)> ContainsOnlyPointers = [&](QualType Ty) {
+      if (isEmptyRecord(getContext(), Ty, true))
+        return false;
+      const RecordType *RT = Ty->getAs<RecordType>();
+      if (!RT)
+        return false;
+      const RecordDecl *RD = RT->getDecl();
+      if (const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
+        for (const auto &I : CXXRD->bases())
----------------
efriedma-quic wrote:

I'm a little uncomfortable with making a clone of isHomogeneousAggregate.  I 
don't see any issues with this right now, but the invariants here are pretty 
subtle, and even if I'm not missing anything right now, something could change.

Not sure what a better solution looks like, though; the current patch might be 
good enough.

-----

Refactoring isHomogeneousAggregate itself to be reusable might work, although 
it's sort of complicated, and it has limitations.

The x86 backend has similar code to do type inference.  But it's currently 
known to be slightly broken; see #76017.

Maybe we want some sort of generic "lowering" function that takes a record, and 
just marks each as either padding, or a suitable primitive type; then targets 
could process that?  Seems a little complicated to design.

https://github.com/llvm/llvm-project/pull/135064
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to