================
@@ -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);
----------------
yqtian-se wrote:
Thanks, done in 240edbbf50c6: every non-empty record is now returned as an
integer array. Each element is no wider than the ABI alignment of the struct
type, so the PTX return parameter keeps its size and alignment. I compared the
PTX signatures of 19 struct and union return shapes before and after, and they
are identical, so this stays compatible with separately compiled device code.
Arguments are not affected, since records are already passed `byval`.
The test changes are the ones you'd expect: `float4_s` in `nvptx-abi.c` and
two OpenMP tests now expect array return types.
I updated the PR body as well to reflect this. Thanks a lot for the suggestion.
https://github.com/llvm/llvm-project/pull/237655
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits