Skip to content

Compile time improvements in the Swift optimizer #64359

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 5 commits into from
Mar 15, 2023

Conversation

eeckstein
Copy link
Contributor

@eeckstein eeckstein commented Mar 14, 2023

This PR contains several compile time improvements in the SwiftCompilerSources.
They add up to significant speedups. E.g. I measured a 2x speedup of EscapeUtils (used in alias analysis).

  • eliminate ARC operations on SIL object classes (which are immortal from the Swift's point of view)
  • speed up Operand.value
  • speed up hasRelevantType in EscapeUtils

For details see the commit messages

@eeckstein
Copy link
Contributor Author

@swift-ci test

@xedin xedin removed their request for review March 14, 2023 18:26
The run time of `Value.hasTrivialNonPointerType` is not negligible, because it does a cache lookup of type lowerings.
Only do this check if it's really needed.
Instead of doing the type casts and/or conformance lookup on the swift side, do it on the C++ side.
It makes a significant performance difference because `Operand.value` is a time critical function
…e SIL objects.

Looking at the SIL I came to the conclusion that `Unmanaged` ins fundamentally broken.
It's easier to directly bitcast between bridged and native SIL objects. It also produces simpler SIL which can be further optimized
…s immortal

A type (mostly classes) can be attributed with `@_semantics("arc.immortal")`.
ARC operations on values of such types are eliminated.

This is useful for the bridged SIL objects in the swift compiler sources.
This avoids ARC operations on those objects which improves compile time.
@eeckstein eeckstein force-pushed the swift-compile-time branch from 2c5f9c7 to 053a38d Compare March 14, 2023 20:07
@eeckstein
Copy link
Contributor Author

@swift-ci test

@eeckstein eeckstein merged commit 7727ce7 into swiftlang:main Mar 15, 2023
@eeckstein eeckstein deleted the swift-compile-time branch March 15, 2023 06:18
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.

1 participant