File tree Expand file tree Collapse file tree 2 files changed +18
-9
lines changed
SILOptimizer/LoopTransforms Expand file tree Collapse file tree 2 files changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -3047,9 +3047,12 @@ const TypeLowering &TypeConverter::getTypeLoweringForLoweredType(
30473047 AbstractionPattern origType, CanType loweredType,
30483048 TypeExpansionContext forExpansion,
30493049 IsTypeExpansionSensitive_t isTypeExpansionSensitive) {
3050- assert (loweredType->isLegalSILType () && " type is not lowered!" );
3051- (void )loweredType;
3052-
3050+
3051+ // For very large types (e.g. tuples with many elements), this assertion is
3052+ // very expensive to execute, because the `isLegalSILType` status is not cached.
3053+ // Therefore the assert is commented out and only here for documentation purposes.
3054+ // assert(loweredType->isLegalSILType() && "type is not lowered!");
3055+
30533056 // Cache the lowered type record for a contextualized type independent of the
30543057 // abstraction pattern. Lowered type parameters can't be cached or looked up
30553058 // without context. (TODO: We could if they match the out-of-context
Original file line number Diff line number Diff line change @@ -937,14 +937,20 @@ void LoopTreeOptimization::analyzeCurrentLoop(
937937 }
938938 }
939939
940- for (auto *AI : ReadOnlyApplies) {
941- if (!mayWriteTo (AA, BCA, sideEffects, AI)) {
942- HoistUp.insert (AI);
940+ // Avoid quadratic complexity in corner cases. Usually, this limit will not be exceeded.
941+ if (ReadOnlyApplies.size () * sideEffects.size () < 8000 ) {
942+ for (auto *AI : ReadOnlyApplies) {
943+ if (!mayWriteTo (AA, BCA, sideEffects, AI)) {
944+ HoistUp.insert (AI);
945+ }
943946 }
944947 }
945- for (auto *LI : Loads) {
946- if (!mayWriteTo (AA, sideEffects, LI)) {
947- HoistUp.insert (LI);
948+ // Avoid quadratic complexity in corner cases. Usually, this limit will not be exceeded.
949+ if (Loads.size () * sideEffects.size () < 8000 ) {
950+ for (auto *LI : Loads) {
951+ if (!mayWriteTo (AA, sideEffects, LI)) {
952+ HoistUp.insert (LI);
953+ }
948954 }
949955 }
950956
You can’t perform that action at this time.
0 commit comments