-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Exclusivity] fix diagnostics for conditional noescape closures. #18234
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
@shajrawi please review. |
@swift-ci test. |
@swift-ci test source compatibility. |
@swift-ci test. |
@swift-ci test source compatibility. |
Build failed |
Build failed |
@swift-ci test. |
@swift-ci test source compatibility. |
Build failed |
Build failed |
@shajrawi can I get a review? |
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.
Overall LGTM! I think you can add llvm_unreachable
(see above) but that's just cosmetic
return cast<SILPHIArgument>(getFalseBB()->getArgument( | ||
operIdx - getFalseOperands().front().getOperandNumber())); | ||
} | ||
return nullptr; |
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.
Shouldn't this be llvm_unreachable
?
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.
In the doc comment:
/// Returns nullptr for an operand with no block argument
/// (i.e the branch condition).
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.
whoops! missed that 👍
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.
I missed it too. Thanks.
Allows a SIL pass to follow a def-use chain through phis. Other terminators can also propagate values through block arguments, but they always need special handling.
Add support to static diagnostics for tracking noescape closures through block arguments. Improve the noescape closure SIL verification logic to match. Cleanup noescape closure handling in both diagnostics and SIL verification to be more robust--they must perfectly match each other. Fixes <rdar://problem/42560459> [Exclusivity] Failure to statically diagnose a conflict when passing conditional noescape closures. Initially reported in [SR-8266] Compiler crash when checking exclusivity of inout alias. Example: struct S { var x: Int mutating func takeNoescapeClosure(_ f: ()->()) { f() } mutating func testNoescapePartialApplyPhiUse(z : Bool) { func f1() { x = 1 // expected-note {{conflicting access is here}} } func f2() { x = 1 // expected-note {{conflicting access is here}} } takeNoescapeClosure(z ? f1 : f2) // expected-error@-1 2 {{overlapping accesses to 'self', but modification requires exclusive access; consider copying to a local variable}} } }
@swift-ci smoke test and merge. |
1 similar comment
@swift-ci smoke test and merge. |
Add support to static diagnostics for tracking noescape closures through block
arguments.
Improve the noescape closure SIL verification logic to match. Cleanup noescape
closure handling in both diagnostics and SIL verification to be more
robust--they must perfectly match each other.
Fixes rdar://problem/42560459 [Exclusivity] Failure to statically diagnose a
conflict when passing conditional noescape closures.
Initially reported in [SR-8266] Compiler crash when checking exclusivity of
inout alias.
Example:
struct S {
var x: Int
mutating func takeNoescapeClosure(_ f: ()->()) { f() }
mutating func testNoescapePartialApplyPhiUse(z : Bool) {
func f1() {
x = 1 // expected-note {{conflicting access is here}}
}
func f2() {
x = 1 // expected-note {{conflicting access is here}}
}
takeNoescapeClosure(z ? f1 : f2)
// expected-error@-1 2 {{overlapping accesses to 'self', but modification requires exclusive access; consider copying to a local variable}}
}
}