-
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 checkEndCOWMutation
Uh oh!
There was an error while loading. Please reload this page.
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.