@@ -3224,11 +3224,31 @@ namespace {
3224
3224
getBitMaskForNoPayloadElements () const override {
3225
3225
// Use the extra inhabitants mask from the payload.
3226
3226
auto &payloadTI = getFixedPayloadTypeInfo ();
3227
- ClusteredBitVector extraInhabitantsMask;
3227
+ APInt extraInhabitantsMaskInt;
3228
+
3229
+ // If we used extra inhabitants from the payload, then we can use the
3230
+ // payload's mask to find the bits we need to test.
3231
+ auto extraDiscriminatorBits = (~APInt (8 , 0 ));
3232
+ if (payloadTI.getFixedSize ().getValueInBits () != 0 )
3233
+ extraDiscriminatorBits =
3234
+ extraDiscriminatorBits.zextOrTrunc (
3235
+ payloadTI.getFixedSize ().getValueInBits ());
3236
+ if (getNumExtraInhabitantTagValues () > 0 ) {
3237
+ extraInhabitantsMaskInt = payloadTI.getFixedExtraInhabitantMask (IGM);
3238
+ // If we have more no-payload cases than extra inhabitants, also
3239
+ // mask in up to four bytes for discriminators we generate using
3240
+ // extra tag bits.
3241
+ if (ExtraTagBitCount > 0 ) {
3242
+ extraInhabitantsMaskInt |= extraDiscriminatorBits;
3243
+ }
3244
+ } else {
3245
+ // If we only use extra tag bits, then we need that extra tag plus
3246
+ // up to four bytes of discriminator.
3247
+ extraInhabitantsMaskInt = extraDiscriminatorBits;
3248
+ }
3249
+ auto extraInhabitantsMask
3250
+ = getBitVectorFromAPInt (extraInhabitantsMaskInt);
3228
3251
3229
- if (!payloadTI.isKnownEmpty (ResilienceExpansion::Maximal))
3230
- extraInhabitantsMask =
3231
- getBitVectorFromAPInt (payloadTI.getFixedExtraInhabitantMask (IGM));
3232
3252
// Extend to include the extra tag bits, which are always significant.
3233
3253
unsigned totalSize
3234
3254
= cast<FixedTypeInfo>(TI)->getFixedSize ().getValueInBits ();
0 commit comments