-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[region-isolation] Since we now propagate the transferred instruction, use that to emit the error instead of attempting to infer the transfer instruction for a requires #69906
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
Conversation
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
…instructions and use it to lookthrough destructures. Currently when one says that an instruction is not a "look through" instruction, each of its results gets a separate element number and we track these results as independent entities that can be in a region. The one issue with this is whenever we perform this sort of operation we actually are at the same time performing a require on the operand of the instruction. This causes us to emit errors on non-side effect having instructions when we really want to emit an error on their side-effect having results. As an example of the world before this patch, the following example would force the struct_element_addr to have a require so we would emit an error on it instead of the apply (the thing that we actually care about): ``` %0 = ... // We transferred %0, so we cannot use it again. apply %transfer(%0) // We track %1 and %0 as separate elements and we treat this as an assignment of // %0 into %1 which forces %0 to be required live at this point causing us to // emit an error here... %1 = struct_element_addr %0 // Instead of in the SIL here on the actual side-effect having instruction. apply %actualUse(%1) ``` the solution is to make instructions like struct_element_addr lookthrough instructions which force their result to just be the same element as their operand. As part of doing this, we have to ensure that getUnderlyingTrackedValue knows how to look through these types. This ensures that they are not considered roots. ---- As an aside to implement this I needed to compose some functionality ontop of getUnderlyingObject (specifically the look through behavior on destructures) in a new helper routine called getUnderlyingTrackedObjectValue(). It just in a loop calls getUnderlyingObject() and looks through destructures until its iterator doesn't change.
Previously if one wanted to get an ASTNode, one needed to use the getAsASTNode<T>() type. If one just wants to get out the type and use it in a generic way using ASTNode there wasn't any way to do this... so I did it. We actually have to do the marshalling here since ASTNodeTy and ASTNode have different layouts despite them both being PointerUnions. So one can't just cast in between them =---(.
Just a better name with better camelCasing.
… to a Sendable value. This came up while I was debugging test cases from the other parts of this work. The specific issue was around a pointer_to_address from a RawPointer (which is considered non-Sendable) to a Sendable type. We were identifying the RawPointer as being the representative of the Sendable value implying we were processing Sendable values like they were non-Sendable. =><=. I wish we had SIL test cases for region isolation since I would add one for this...
…sfer instructions. This is another NFC refactor in preparation for changing how we emit errors. Specifically, we need access to not only the instruction, but also the specific operand that the transfer occurs at. This ensures that we can look up the specific type information later when we emit an error rather than tracking this information throughout the entire pass.
… original type, just derive the type from the transfer operand when we emit the error.
…sible requires... just emit a diagnostic on the first require that we see. This involved me removing the complex logic for emitting diagnostics we have today in favor of a simple diagnostic that works by: 1. Instead of searching for transfer instructions, we use the transfer instruction that we propagated by the dataflow... so there is no way for us to possible not identify a transfer instruction... we always have it. 2. Instead of emitting diagnostics for all requires, just emit a warning for the first require we see along a path. The reason that we need to do this is that in certain cases we will have multiple "require" instructions from slightly different source locations (e.x.: differing by column) but on the same line. I saw this happen specifically with print where we treat stores into the array as a require as well as the actual call to print itself where we pass the array. An additional benefit of this is that this allowed me to get rid of the cache of already seen require instructions. By doing this, we now emit errors when the same apply needs to be required by different transfer instructions for different arguments. NOTE: I left in the original implementation code to make it easier to review this new code. I deleted it in the next commit. Otherwise the git diff for this patch is too difficult to read.
Contributor
Author
|
@swift-ci smoke test |
Contributor
Author
|
@swift-ci smoke test linux platform |
Contributor
Author
|
I just talked with Slava... we are going to do post commit review on this. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
In this PR, I transition the pass from attempting to infer from regions transfer instructions, just use the newly propagated transfer instruction.
Here is a guide to the PR.
The next set of patches are tied together and have to do with the actual main work of this PR. I split it up to make it easier to review.