[PATCH] D49464: [COFF, ARM64] Mark only POD-type returns as SRET

Mandeep Singh Grang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 23 17:00:17 PDT 2018


mgrang added a comment.

In https://reviews.llvm.org/D49464#1170710, @rnk wrote:

> In https://reviews.llvm.org/D49464#1170686, @efriedma wrote:
>
> > Reid, are you okay with merging something like the current patch for now, and implementing returning the value as a followup?
>
>
> Yeah.
>
> Please add some test cases that verify that the right thing happens for instance methods returning POD structs. Should the sret parameter be in X1 or X8? Looks like you want X1, so `isPOD` isn't the right check.
>
>   struct IsPOD { int x; };
>   struct Foo {
>     IsPOD foo() { return IsPOD{3}; }
>   };
>   int main() {
>     return Foo().foo().x;
>   }
>


The ABI doc just distinguishes between POD and non-POD types.

  The address of the memory block shall be passed as an additional argument to the function in x8 for POD type, or in x0 (or x1 if $this is passed in x0) for non-POD type.

So even for instance methods returning PODs, X8 should be used.


https://reviews.llvm.org/D49464





More information about the llvm-commits mailing list