Skip to content

Commit 0e673f7

Browse files
committed
Fix misalignment of conditional invertible requirement counts
1 parent a31d15c commit 0e673f7

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

include/swift/ABI/GenericContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ class TrailingGenericContextObjects<TargetSelf<Runtime>,
696696
if (!asSelf()->hasConditionalInvertedProtocols())
697697
return 0;
698698

699-
return countBitsUsed(getConditionalInvertedProtocols().rawBits());
699+
return __builtin_popcount(getConditionalInvertedProtocols().rawBits());
700700
}
701701

702702
size_t numTrailingObjects(

lib/IRGen/GenMeta.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,13 @@ namespace {
13341334
B.addPlaceholderWithSize(IGM.Int16Ty));
13351335
}
13361336

1337+
// The conditional invertible protocol set is alone as a 16 bit slot, so
1338+
// an even amount of conditional invertible protocols will cause an uneven
1339+
// alignment.
1340+
if ((numProtocols & 1) == 0) {
1341+
B.addInt16(0);
1342+
}
1343+
13371344
// Emit the generic requirements for the conditional conformance
13381345
// to each invertible protocol.
13391346
auto nominal = cast<NominalTypeDecl>(Type);

0 commit comments

Comments
 (0)