-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Performance diagnostics] Enable checking of throw instructions #77752
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
Conversation
This builds on #77748. That PR made typed throws avoid allocations in practice, lifting a restriction. This PR removes the hack that allowed untyped throws through the performance-annotation checker, even though they would allocate. So this PR tightens up performance annotation checking in a way that may reject existing code (that should always have been rejected). |
@swift-ci please smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the declaration of neBlocks
, too. And at that occasion also in visitFunctionEmbeddedSwift
.
You can remove the NonErrorHandlingBlocks
utility at all. It's not used anywhere else and we will not need it anymore - at least not in C++.
Prior to throwing, Swift emits a call to `swift_willThrow(Typed)`, which allows various diagnostic tools (such as debuggers and testing libraries) to intercept errors at the point where they are initially thrown. Since `swift_willThrow(Typed)` can be hooked by arbitrary code at runtime, there is no way for it to meet performance constraints like @_noLocks or @_noAllocation. Therefore, in a function that has those performance constraints specified, disable emission of the call to `swift_willThrow(Typed)`. Fixes rdar://140230684.
c354f90
to
7d73aab
Compare
Rebased on top of #77780, removed |
@swift-ci please smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, thanks!
7d73aab
to
131bd17
Compare
@swift-ci please smoke test |
When performance diagnostics were introduced, typed throws didn't exist so it was not generally possible to have throws anywhere without triggering performance diagnostics. As a short term hack, we disabled checking of `throw` instructions and the basic blocks that terminate in a `throw`. Now that typed throws is available and can be used to eliminate allocations with error handling, remove all of the hacks. We'll now diagnose attempts to throw or catch existential values (e.g., the `any Error` used for untyped throws), but typed throws are fine.
131bd17
to
1d3332d
Compare
@swift-ci please smoke test |
@swift-ci please smoke test macOS |
When performance diagnostics were introduced, typed throws didn't exist
so it was not generally possible to have throws anywhere without
triggering performance diagnostics. As a short term hack, we disabled
checking of
throw
instructions and the basic blocks that terminatein a
throw
.Now that typed throws is available and can be used to eliminate
allocations with error handling, remove all of the hacks. We'll now
diagnose attempts to throw or catch existential values (e.g., the
any Error
used for untyped throws), but typed throws are fine.