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

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 2 15:55:33 PDT 2026


================
@@ -79,6 +79,35 @@ struct CIRRecordLowering final {
         cir::ArrayType::get(cirGenTypes.convertTypeForMem(field->getType()), 0),
         cir::RecordMemberKind::BitField);
   }
+
+  /// An access unit can be narrower than the types its bit-fields were
+  /// declared with.  In `struct { int a : 4; int b : 11; int c : 17; }` all
+  /// three share one 4-byte unit, but `c` is declared `int`, so the declared
+  /// data runs 15 bits past the unit:
+  ///
+  ///   |-a-|----b-----|-------c--------|
+  ///   |--------- 4-byte unit ---------|--- extent ---|
+  ///                  |------ c declared as int ------|
+  ///   0   4          15               32             47  bits
----------------
andykaylor wrote:

I don't understand this example. Since a, b, and c, all fit within a single 32-bit integer, there is no need for c to extend beyond the 32 bits. Why are we recording anything here?

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


More information about the cfe-commits mailing list