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

Conversation

eeckstein
Copy link
Contributor

@eeckstein eeckstein commented Jan 4, 2023

  • Comment out an expensive assert in type lowering

For very large types (e.g. tuples with many elements), this assertion is very expensive to execute, because the isLegalSILType status is not cached.

  • LICM: add limits for the number of alias checks to avoid large compile times in corner cases

Avoids quadratic complexity in corner cases. Usually, these limits will not be exceeded.

Resolves #62837

…e times in corner cases

Avoid quadratic complexity in corner cases. Usually, these limits will not be exceeded.
For very large types (e.g. tuples with many elements), this assertion is very expensive to execute, because the `isLegalSILType` status is not cached.
@eeckstein
Copy link
Contributor Author

@swift-ci test

@eeckstein eeckstein requested a review from atrick January 4, 2023 15:05
@eeckstein
Copy link
Contributor Author

@swift-ci test macos

@eeckstein
Copy link
Contributor Author

@swift-ci test macos

@eeckstein eeckstein merged commit 0144fb6 into swiftlang:main Jan 5, 2023
@eeckstein eeckstein deleted the fix-compiletime-bugs branch January 5, 2023 06:32
@atrick
Copy link
Contributor

atrick commented Jan 7, 2023

@eeckstein I don't have any big concern with these changes. But loops didn't become bigger and types didn't become bigger. So it would be interesting to know why asking for a lowered SIL type or querying AA suddenly caused the compiler to "hang".

@eeckstein
Copy link
Contributor Author

@atrick The main problem was the assert in getTypeLoweringForLoweredType. The old escape analysis had its own implementation for checking if a type is a "pointer" type. So it didn't use this code.
I believe, the problem in LICM always caused compile time problems, but we didn't notice so far.

@atrick
Copy link
Contributor

atrick commented Jan 10, 2023

@eeckstein I wonder why that assert was checked before the cache lookup. It might be beneficial to run after a cache failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Source compatibility suite] swift compiler hanging when attempting to build swift-nio file Utilities.swift
2 participants