[clang] [CIR] Add support for discrete bit-field (PR #156085)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 29 17:01:32 PDT 2025
================
@@ -306,7 +316,45 @@ void CIRRecordLowering::fillOutputFields() {
RecordDecl::field_iterator
CIRRecordLowering::accumulateBitFields(RecordDecl::field_iterator field,
RecordDecl::field_iterator fieldEnd) {
- assert(!cir::MissingFeatures::isDiscreteBitFieldABI());
+ if (isDiscreteBitFieldABI()) {
+ // run stores the first element of the current run of bitfields. fieldEnd is
+ // used as a special value to note that we don't have a current run. A
+ // bitfield run is a contiguous collection of bitfields that can be stored
+ // in the same storage block. Zero-sized bitfields and bitfields that would
+ // cross an alignment boundary break a run and start a new one.
+ RecordDecl::field_iterator run = fieldEnd;
+ // tail is the offset of the first bit off the end of the current run. It's
+ // used to determine if the ASTRecordLayout is treating these two bitfields
+ // as contiguous. StartBitOffset is offset of the beginning of the Run.
+ uint64_t startBitOffset, tail = 0;
+ for (; field != fieldEnd && field->isBitField(); ++field) {
+ // Zero-width bitfields end runs.
+ if (field->isZeroLengthBitField()) {
----------------
andykaylor wrote:
Can you add a test case or two that encounter this condition?
https://github.com/llvm/llvm-project/pull/156085
More information about the cfe-commits
mailing list