================
@@ -15941,15 +15945,18 @@ struct PaddingCalculator {
     // the partially occupied bytes in either end, if present, their bit
     // intervals need to be adjusted so that they count from the MSB instead.
     //
-    // FIXME: For over-sized bitfields in BE, Clang allocates padding bits
-    // before the occupied bits. This violates the ABI rules, which say that
-    // padding should be allocated after, regardless of endianness (Itanium C++
-    // ABI ยง2.4, II.1(b)). The current code accommodates for Clang's current
-    // behaviour though, and bumps Start forward to skip the leading padding
-    // bits.
-    const uint64_t Start =
-        StartBitOffset + DeclaredSizeInBits - OccupiedSizeInBits;
-    const uint64_t End = Start + OccupiedSizeInBits;
+    // Occupied bits are allocated first, and any padding follows them.
+    const uint64_t Start = StartBitOffset;
+    // A _BitInt(N) bit-field may be declared wider than N, e.g.
+    // `_BitInt(5) a : 6`. CodeGen stores the value in the low-order N bits of
+    // the field, which are allocated last on big-endian (01111100), so the
+    // leading bits are not value bits. Treat the field as occupied up to the
+    // storage size of _BitInt(N) so that the value bits are never cleared.
+    // Bits beyond the storage size are padding.
----------------
vhscampos wrote:

After the changes I suggested, I'm not sure we need to have this explanation 
anymore.

https://github.com/llvm/llvm-project/pull/225494
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to