[clang] [CIR] Mark bit-field access units as their own member kinds (PR #216864)

Adam Smith via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 18 12:51:13 PDT 2026


================
@@ -148,10 +148,18 @@ struct CIRRecordLowering final {
     return cirGenTypes.isZeroInitializable(rd);
   }
 
+  static cir::RecordMemberKind makeMemberKind(bool holdsData, bool isUnit) {
----------------
adams381 wrote:

A "unit" is classic's bit-field access unit, the storage CodeGen allocates for a contiguous run of bit-fields.  Classic uses the term and defines it in `CGRecordLayoutBuilder.cpp`, in a 50 line comment block running from line 451 to 503:

```c++
...
// We split runs of bit-fields into a sequence of "access units". When we emit
// a load or store of a bit-field, we'll load/store the entire containing
// access unit. As mentioned, the standard requires that these loads and
// stores must not interfere with accesses to other memory locations, and it
// defines the bit-field's memory location as the current run of
// non-zero-width bit-fields. So an access unit must never overlap with
// non-bit-field storage or cross a zero-width bit-field. Otherwise, we're
// free to draw the lines as we see fit.
...
```

Our `accumulateBitFields` is a port of that function, so it is the same concept, and the mark exists because the unit's width is the compiler's choice rather than the declared type of the bit-fields inside it.

What is the policy on reusing a comment in a separate part of the compiler?  Copy it verbatim, adapt a condensed version, or just point at the classic file?

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


More information about the cfe-commits mailing list