[PATCH] D81583: Update SystemZ ABI to handle C++20 [[no_unique_address]] attribute

Ulrich Weigand via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 10 09:17:50 PDT 2020


uweigand created this revision.
uweigand added reviewers: craig.topper, erichkeane, jasonliu, kbarton, rnk, asl, sunfish, t.p.northover, arsenm, asb.
Herald added subscribers: cfe-commits, wdng.
Herald added a project: clang.

The SystemZ ABI has special cases to handle structs containing just a single floating-point member.  In determining this property, there are corner cases around empty fields.  So for example, if a struct contains an "empty member" in addition to a member of floating-point type, the struct is still considered to contain just a single floating-point member.

In (prior versions of) C++, however, members of class type would never count as "empty" given the C++ rules that even an empty class should be considered as having a size of at least 1.   But now with C++20, data members can be marked with the [[no_unique_address]] attribute, in which case that rule no longer applies.  The Itanium ABI document was updated to address this new situation (https://itanium-cxx-abi.github.io/cxx-abi/abi.html#definitions):

> 
> 
>   empty class
>      A class with no non-static data members other than empty data members, no unnamed bit-fields other than zero-width bit-fields, no virtual functions, no virtual base classes, and no non-empty non-virtual proper base classes.
>    
> 
> empty data member
> 
>   A potentially-overlapping non-static data member of empty class type. 

GCC 10 has been updated across platforms to respect this new case.

This patch implements the new case in the ABI code for SystemZ.  Note that I'm changing common subroutines (isEmptyField / isEmptyRecord) that are used for other ABIs as well.  To prevent this patch from having any unintended effect on other platforms, I've guarded the new behavior with an extra flag that is currently only set on SystemZ.

Now I would expect that most other platforms who use isEmptyField / isEmptyRecord / isSingleElementStruct / isHomogeneousAggregate will also have to respect that new behavior in order to stay compatible with the respective system ABIs (and GCC), but I'd prefer to leave this up to the maintainers of those platforms ...


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81583

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/systemz-abi.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81583.269863.patch
Type: text/x-patch
Size: 6530 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200610/e04ccfe3/attachment.bin>


More information about the cfe-commits mailing list