Skip to content

Fix two compile-time bugs #62830

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/SIL/IR/TypeLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3047,9 +3047,12 @@ const TypeLowering &TypeConverter::getTypeLoweringForLoweredType(
AbstractionPattern origType, CanType loweredType,
TypeExpansionContext forExpansion,
IsTypeExpansionSensitive_t isTypeExpansionSensitive) {
assert(loweredType->isLegalSILType() && "type is not lowered!");
(void)loweredType;


// For very large types (e.g. tuples with many elements), this assertion is
// very expensive to execute, because the `isLegalSILType` status is not cached.
// Therefore the assert is commented out and only here for documentation purposes.
// assert(loweredType->isLegalSILType() && "type is not lowered!");

// Cache the lowered type record for a contextualized type independent of the
// abstraction pattern. Lowered type parameters can't be cached or looked up
// without context. (TODO: We could if they match the out-of-context
Expand Down
18 changes: 12 additions & 6 deletions lib/SILOptimizer/LoopTransforms/LICM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -937,14 +937,20 @@ void LoopTreeOptimization::analyzeCurrentLoop(
}
}

for (auto *AI : ReadOnlyApplies) {
if (!mayWriteTo(AA, BCA, sideEffects, AI)) {
HoistUp.insert(AI);
// Avoid quadratic complexity in corner cases. Usually, this limit will not be exceeded.
if (ReadOnlyApplies.size() * sideEffects.size() < 8000) {
for (auto *AI : ReadOnlyApplies) {
if (!mayWriteTo(AA, BCA, sideEffects, AI)) {
HoistUp.insert(AI);
}
}
}
for (auto *LI : Loads) {
if (!mayWriteTo(AA, sideEffects, LI)) {
HoistUp.insert(LI);
// Avoid quadratic complexity in corner cases. Usually, this limit will not be exceeded.
if (Loads.size() * sideEffects.size() < 8000) {
for (auto *LI : Loads) {
if (!mayWriteTo(AA, sideEffects, LI)) {
HoistUp.insert(LI);
}
}
}

Expand Down