[PATCH] D127197: [ARM] Fix how size-0 bitfields affect homogeneous aggregates.

Simon Tatham via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 7 03:57:19 PDT 2022


simon_tatham created this revision.
simon_tatham added reviewers: asl, rsmith, lenary, john.brawn.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
simon_tatham requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

By both AAPCS32 and AAPCS64, the test for whether an aggregate
qualifies as homogeneous (either HFA or HVA) is based on the data
layout alone. So any logical member of the structure that does not
affect the data layout also should not affect homogeneity. In
particular, an empty bitfield ('int : 0') should make no difference.

In fact, clang considered it to make a difference in C but not in C++,
and justified that policy as compatible with gcc. But that's
considered a bug in gcc as well (at least for Arm targets), and it's
fixed in gcc 12.1.

This fix mimics gcc's: zero-sized bitfields are now ignored in all
languages for the Arm (32- and 64-bit) ABIs. But I've left the
previous behaviour unchanged in other ABIs, by means of adding an
ABIInfo::isZeroLengthBitfieldPermittedInHomogeneousAggregate query
method which the Arm subclasses override.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127197

Files:
  clang/lib/CodeGen/ABIInfo.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/homogeneous-aggregates.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127197.434767.patch
Type: text/x-patch
Size: 7338 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220607/bad72166/attachment-0001.bin>


More information about the cfe-commits mailing list