[clang] [clang] Better bitfield access units (PR #65742)

Nathan Sidwell via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 8 11:41:33 PST 2024


urnathan wrote:

This update 
* moves the creation and installation of the BitFieldAccessUnit objects into CGRecordLowering.
* adds aarch64 and arm darwin target tests, as those have different layout rules (let me know if I've missed something here).
* Simplifies the checking of barriers -- an explicit flag, rather than inferring from a zero-sized unit.  The latter can represent a non-barrier that happens to fall at a byte boundary, and results in a simplification of the gathering operation.
* changes the API of accumulateBitFields to return the following non-bitfield.  This means that the caller does not itself have to scan across the bitfields to find their range. Given the bitfield processor has scan the bitfields anyway, this seems like a win.
* because of that, the determination of the limiting boundary, only needed for non-ms abis, is moved to where it is needed.

FWIW, I experimented with the representation in BitFieldAccessUnit:
* Although adjacent units are contiguous and it would seem one of Begin and End is unneeded, it turned out easiest to have both -- omitting Begin simply makes the calling code to the bookwork
* Whether to represent access unit boundaries as bit or char offsets.  Whichever is chosen leads to conversions to the other representation at various points. Using chars was the least painful, and makes it clear these are char boundaries.

It might be possible to go further and perform the accumulation you outlined above, but there's enough churn in this update that I thought it best to push it.

https://github.com/llvm/llvm-project/pull/65742


More information about the cfe-commits mailing list