@@ -2529,17 +2529,15 @@ CanSILBoxType TypeConverter::getBoxTypeForEnumElement(SILType enumType,
2529
2529
}
2530
2530
2531
2531
static void countNumberOfInnerFields (unsigned &fieldsCount, SILModule &Module,
2532
- SILType Ty) {
2532
+ SILType Ty, ResilienceExpansion expansion ) {
2533
2533
if (auto *structDecl = Ty.getStructOrBoundGenericStruct ()) {
2534
- // FIXME: Expansion
2535
- assert (!structDecl->isResilient (Module.getSwiftModule (),
2536
- ResilienceExpansion::Minimal) &&
2534
+ assert (!structDecl->isResilient (Module.getSwiftModule (), expansion) &&
2537
2535
" FSO should not be trying to explode resilient (ie address-only) "
2538
2536
" types at all" );
2539
2537
for (auto *prop : structDecl->getStoredProperties ()) {
2540
2538
SILType propTy = Ty.getFieldType (prop, Module);
2541
2539
unsigned fieldsCountBefore = fieldsCount;
2542
- countNumberOfInnerFields (fieldsCount, Module, propTy);
2540
+ countNumberOfInnerFields (fieldsCount, Module, propTy, expansion );
2543
2541
if (fieldsCount == fieldsCountBefore) {
2544
2542
// size of Struct(BigStructType) == size of BigStructType()
2545
2543
// prevent counting its size as BigStructType()+1
@@ -2549,19 +2547,17 @@ static void countNumberOfInnerFields(unsigned &fieldsCount, SILModule &Module,
2549
2547
return ;
2550
2548
}
2551
2549
if (auto tupleTy = Ty.getAs <TupleType>()) {
2552
- for (auto elt : tupleTy-> getElementTypes ()) {
2553
- auto silElt = SILType::getPrimitiveObjectType (elt-> getCanonicalType () );
2554
- countNumberOfInnerFields (fieldsCount, Module, silElt);
2550
+ for (auto elt : tupleTy. getElementTypes ()) {
2551
+ auto silElt = SILType::getPrimitiveObjectType (elt);
2552
+ countNumberOfInnerFields (fieldsCount, Module, silElt, expansion );
2555
2553
}
2556
2554
return ;
2557
2555
}
2558
2556
if (auto *enumDecl = Ty.getEnumOrBoundGenericEnum ()) {
2559
2557
if (enumDecl->isIndirect ()) {
2560
2558
return ;
2561
2559
}
2562
- // FIXME: Expansion
2563
- assert (!enumDecl->isResilient (Module.getSwiftModule (),
2564
- ResilienceExpansion::Minimal) &&
2560
+ assert (!enumDecl->isResilient (Module.getSwiftModule (), expansion) &&
2565
2561
" FSO should not be trying to explode resilient (ie address-only) "
2566
2562
" types at all" );
2567
2563
unsigned fieldsCountBefore = fieldsCount;
@@ -2580,7 +2576,7 @@ static void countNumberOfInnerFields(unsigned &fieldsCount, SILModule &Module,
2580
2576
// In case it is used by a pass that tries to explode enums.
2581
2577
auto payloadTy = Ty.getEnumElementType (elt, Module);
2582
2578
fieldsCount = 0 ;
2583
- countNumberOfInnerFields (fieldsCount, Module, payloadTy);
2579
+ countNumberOfInnerFields (fieldsCount, Module, payloadTy, expansion );
2584
2580
if (fieldsCount > maxEnumCount) {
2585
2581
maxEnumCount = fieldsCount;
2586
2582
}
@@ -2590,13 +2586,15 @@ static void countNumberOfInnerFields(unsigned &fieldsCount, SILModule &Module,
2590
2586
}
2591
2587
}
2592
2588
2593
- unsigned TypeConverter::countNumberOfFields (SILType Ty) {
2594
- auto Iter = TypeFields.find (Ty);
2589
+ unsigned TypeConverter::countNumberOfFields (SILType Ty,
2590
+ ResilienceExpansion expansion) {
2591
+ auto key = std::make_pair (Ty, unsigned (expansion));
2592
+ auto Iter = TypeFields.find (key);
2595
2593
if (Iter != TypeFields.end ()) {
2596
2594
return std::max (Iter->second , 1U );
2597
2595
}
2598
2596
unsigned fieldsCount = 0 ;
2599
- countNumberOfInnerFields (fieldsCount, M, Ty);
2600
- TypeFields[Ty ] = fieldsCount;
2597
+ countNumberOfInnerFields (fieldsCount, M, Ty, expansion );
2598
+ TypeFields[key ] = fieldsCount;
2601
2599
return std::max (fieldsCount, 1U );
2602
2600
}
0 commit comments