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(
3047
3047
AbstractionPattern origType, CanType loweredType,
3048
3048
TypeExpansionContext forExpansion,
3049
3049
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
+
3053
3056
// Cache the lowered type record for a contextualized type independent of the
3054
3057
// abstraction pattern. Lowered type parameters can't be cached or looked up
3055
3058
// 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(
937
937
}
938
938
}
939
939
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
+ }
943
946
}
944
947
}
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
+ }
948
954
}
949
955
}
950
956
You can’t perform that action at this time.
0 commit comments