@@ -2529,17 +2529,15 @@ CanSILBoxType TypeConverter::getBoxTypeForEnumElement(SILType enumType,
25292529}
25302530
25312531static void countNumberOfInnerFields (unsigned &fieldsCount, SILModule &Module,
2532- SILType Ty) {
2532+ SILType Ty, ResilienceExpansion expansion ) {
25332533 if (auto *structDecl = Ty.getStructOrBoundGenericStruct ()) {
2534- // FIXME: Expansion
2535- assert (!structDecl->isResilient (Module.getSwiftModule (),
2536- ResilienceExpansion::Minimal) &&
2534+ assert (!structDecl->isResilient (Module.getSwiftModule (), expansion) &&
25372535 " FSO should not be trying to explode resilient (ie address-only) "
25382536 " types at all" );
25392537 for (auto *prop : structDecl->getStoredProperties ()) {
25402538 SILType propTy = Ty.getFieldType (prop, Module);
25412539 unsigned fieldsCountBefore = fieldsCount;
2542- countNumberOfInnerFields (fieldsCount, Module, propTy);
2540+ countNumberOfInnerFields (fieldsCount, Module, propTy, expansion );
25432541 if (fieldsCount == fieldsCountBefore) {
25442542 // size of Struct(BigStructType) == size of BigStructType()
25452543 // prevent counting its size as BigStructType()+1
@@ -2549,19 +2547,17 @@ static void countNumberOfInnerFields(unsigned &fieldsCount, SILModule &Module,
25492547 return ;
25502548 }
25512549 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 );
25552553 }
25562554 return ;
25572555 }
25582556 if (auto *enumDecl = Ty.getEnumOrBoundGenericEnum ()) {
25592557 if (enumDecl->isIndirect ()) {
25602558 return ;
25612559 }
2562- // FIXME: Expansion
2563- assert (!enumDecl->isResilient (Module.getSwiftModule (),
2564- ResilienceExpansion::Minimal) &&
2560+ assert (!enumDecl->isResilient (Module.getSwiftModule (), expansion) &&
25652561 " FSO should not be trying to explode resilient (ie address-only) "
25662562 " types at all" );
25672563 unsigned fieldsCountBefore = fieldsCount;
@@ -2580,7 +2576,7 @@ static void countNumberOfInnerFields(unsigned &fieldsCount, SILModule &Module,
25802576 // In case it is used by a pass that tries to explode enums.
25812577 auto payloadTy = Ty.getEnumElementType (elt, Module);
25822578 fieldsCount = 0 ;
2583- countNumberOfInnerFields (fieldsCount, Module, payloadTy);
2579+ countNumberOfInnerFields (fieldsCount, Module, payloadTy, expansion );
25842580 if (fieldsCount > maxEnumCount) {
25852581 maxEnumCount = fieldsCount;
25862582 }
@@ -2590,13 +2586,15 @@ static void countNumberOfInnerFields(unsigned &fieldsCount, SILModule &Module,
25902586 }
25912587}
25922588
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);
25952593 if (Iter != TypeFields.end ()) {
25962594 return std::max (Iter->second , 1U );
25972595 }
25982596 unsigned fieldsCount = 0 ;
2599- countNumberOfInnerFields (fieldsCount, M, Ty);
2600- TypeFields[Ty ] = fieldsCount;
2597+ countNumberOfInnerFields (fieldsCount, M, Ty, expansion );
2598+ TypeFields[key ] = fieldsCount;
26012599 return std::max (fieldsCount, 1U );
26022600}
0 commit comments