================
@@ -177,6 +199,16 @@ ABIArgInfo NVPTXABIInfo::classifyReturnType(QualType 
RetTy) const {
       isUnsupportedType(RetTy))
     return coerceToIntArrayWithLimit(RetTy, 64);
 
+  // Return an aggregate that contains a union as an integer array of the same
+  // size. Use the original LLVM type's ABI alignment for the array elements
+  // so the PTX return parameter keeps its alignment while all bytes of the
+  // active union member are returned.
+  if (isOrContainsUnion(getContext(), RetTy)) {
+    unsigned Align =
+        getDataLayout().getABITypeAlign(CGT.ConvertType(RetTy)).value() * 8;
+    return coerceToIntArrayWithLimit(RetTy, Align);
----------------
efriedma-quic wrote:

Splitting a struct into its component fields will given weird results in 
general for structs with padding, even if there isn't a union.

Most targets transform to an array by default.  See also #185083.

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

Reply via email to