[PATCH] D151298: [clang][LoongArch] Fix the calling convention for empty struct in C++ mode

wanglei via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 24 00:12:01 PDT 2023


wangleiat added a comment.

In D151298#4367163 <https://reviews.llvm.org/D151298#4367163>, @xry111 wrote:

> Blocking this as it's a deliberate decision made in D132285 <https://reviews.llvm.org/D132285>.
>
> Is there any imperative reason we must really pass the empty struct?  The C++ standard only treats struct {} as size 1 for the semantics of pointer comparison.  While there is no pointers to registers, ignoring it in the register calling convention will make no harm.
>
> And AFAIK it will be an undefined behavior attempting to (mis)use the padding space of/after the empty struct to pass any information.



In D151298#4367163 <https://reviews.llvm.org/D151298#4367163>, @xry111 wrote:

> Blocking this as it's a deliberate decision made in D132285 <https://reviews.llvm.org/D132285>.
>
> Is there any imperative reason we must really pass the empty struct?  The C++ standard only treats struct {} as size 1 for the semantics of pointer comparison.  While there is no pointers to registers, ignoring it in the register calling convention will make no harm.
>
> And AFAIK it will be an undefined behavior attempting to (mis)use the padding space of/after the empty struct to pass any information.

Our current modifications are closer to the description of `Itanium C++ ABI`, and we try to keep it consistent with the description of the calling convention under `reasonable premise`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151298/new/

https://reviews.llvm.org/D151298



More information about the cfe-commits mailing list