[clang] [CIR] Record how far a bit-field's declared types reach on x86_64 (PR #220069)

Adam Smith via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 2 05:47:36 PDT 2026


================
@@ -79,6 +79,24 @@ struct CIRRecordLowering final {
         cir::ArrayType::get(cirGenTypes.convertTypeForMem(field->getType()), 0),
         cir::RecordMemberKind::BitField);
   }
+
+  /// A member recording that declared types reach \p excessInBits past where
+  /// it sits.  An access unit's width is the compiler's choice, so it can be
+  /// narrower than the types declared in it, and the ABI reads that reach to
+  /// tell the bytes after the unit from padding.  A zero-length array holds
+  /// no storage, and `isZeroWidthBitField` answers true for it as well as for
+  /// a zero-width bit-field, so the layout walks pass over both.
+  ///
+  /// The bits counted are those past the member, not past the unit: a
+  /// zero-sized member reports the offset where the storage ahead of it ends,
+  /// so a caller measuring from anywhere else claims bytes twice.
+  MemberInfo makeDeclaredReachInfo(CharUnits offset, uint64_t excessInBits) {
----------------
adams381 wrote:

I've renamed to `makeDeclaredExtentInfo`, which parallels `makeZeroWidthBitFieldInfo` directly above it.  If the representation changes as proposed in my top-level comment, this helper goes away entirely.

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


More information about the cfe-commits mailing list