This is an archive of the discontinued LLVM Phabricator instance.

[MS] Apply `inreg` to AArch64 sret parms on instance methods
ClosedPublic

Authored by rnk on Oct 13 2020, 8:03 PM.

Details

Summary

The documentation rules indicate that instance methods should return
large, trivially copyable aggregates via X1/X0 and not X8 as is normally
done when returning such structs from free functions:
https://docs.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=vs-2019#return-values

Fixes PR47836, a bug in the initial implementation of these rules.

I tried to simplify the logic a bit as well while I'm here.

Diff Detail

Unit TestsFailed

Event Timeline

rnk created this revision.Oct 13 2020, 8:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 13 2020, 8:03 PM
rnk requested review of this revision.Oct 13 2020, 8:03 PM
efriedma added inline comments.Oct 13 2020, 9:47 PM
clang/lib/CodeGen/MicrosoftCXXABI.cpp
1077

This is just reversing the result of the function, I guess.

1108

isTrivialForABI is only used if isAArch64 is true, so it shouldn't use isTrivialForABI as part of its computation, I think?

1110

I suspect that the IsSizeGreaterThan128() check shouldn't be here. Can we rely on the C ABI rules for that?

For non-AArch64, is it really correct to use isPOD()? That varies based on the language version, no?

rnk added inline comments.Oct 14 2020, 9:41 AM
clang/lib/CodeGen/MicrosoftCXXABI.cpp
1108

I see. I think we ended up with this tortured condition because I gave review feedback that it would be good to avoid checking isCXX14Aggregate (formerly hasMicrosoftABIRestritions) for non-aarch64 targets. I'll take another shot at simplifying things.

1110

I think you are right, we can remove the size check here, it's already part of what feeds into RD->canPassInRegisters. There is an earlier size check here:
https://github.com/llvm/llvm-project/blob/master/clang/lib/Sema/SemaDeclCXX.cpp#L6441

I agree isPOD is vague, but the comments on the implementation do say this:

/// Note that this is the C++ TR1 definition of POD.

So, I think it doesn't vary in practice.

rnk updated this revision to Diff 298473.Oct 15 2020, 2:38 PM
  • simplify some more
efriedma accepted this revision.Oct 15 2020, 2:47 PM

Makes a lot more sense now. LGTM

This revision is now accepted and ready to land.Oct 15 2020, 2:47 PM
This revision was landed with ongoing or failed builds.Oct 15 2020, 3:00 PM
This revision was automatically updated to reflect the committed changes.