-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Teach stripCasts (and getUnderlyingObject) about begin_access. #32842
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 was blocking EscapeAnalysis and many other analyses from handling access markers.
@@ -145,7 +146,8 @@ SILValue swift::stripCasts(SILValue v) { | |||
auto k = v->getKind(); | |||
if (isRCIdentityPreservingCast(k) | |||
|| k == ValueKind::UncheckedTrivialBitCastInst | |||
|| k == ValueKind::MarkDependenceInst) { | |||
|| k == ValueKind::MarkDependenceInst | |||
|| k == ValueKind::BeginAccessInst) { |
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.
@eeckstein I don't know why stripCasts
does not check EndCOWMutation
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.
It's a longer story: when I added end_cow_mutation, I came to the conclusion that those global stripWhatEver utility functions are not such a good idea.
Let's take stripCasts as example: every optimization has (or could have) a different view of what a cast instruction is. For EscapeAnalysis a begin_access is the same as a cast. But that's not necessarily true for other optimizations, which might need to treat begin_access separately.
I think it's better to let each optimization/analysis contain there own strip... functions, even if this means some code duplication.
Then it's much easier to modify them and add instructions as needed without worrying about other optimizations.
That's why I added end_cow_mutation only at those places where it was really needed and not in the global strip functions.
... and unfortunately, never came back to remove the global strip functions at all.
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.
The strip utilities are not good abstractions for a high-level IR like SIL. I also did not want to modify them when adding the access markers. But not handling access markers has been blocking progress recently, and migrating passes away from the strip functions will take more time.
We now have an AccessUseDefVisitor that more properly abstracts over address and pointer operations, allowing passes to override some of the behavior without copying a giant switch statement everywhere. I'll demonstrate this in some upcoming PRs... And for every use-def abstraction, we need a matching def-use abstraction.
More importantly, an abstraction is useful if we can use it impose some order on SIL, defining which patterns are valid SIL and enforcing that in the verifier. In some situations, we can't simply bail-out on unrecognized patterns, so we need an abstraction that's guaranteed to work everywhere.
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.
Don't get me wrong: I think this PR is fine. I just wanted to answer the question why end_cow_mutation is not handled in stripCasts.
@swift-ci test |
@swift-ci benchmark |
@swift-ci test source compatibility |
Build failed |
Performance: -O
Code size: -O
Performance: -Osize
Code size: -OsizePerformance: -Onone
Code size: -swiftlibsHow to read the dataThe tables contain differences in performance which are larger than 8% and differences in code size which are larger than 1%.If you see any unexpected regressions, you should consider fixing the Noise: Sometimes the performance results (not code size!) contain false Hardware Overview
|
@swift-ci test macos platform |
This was blocking EscapeAnalysis and many other analyses from handling
access markers.