-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[WIP] SILGen: Capture address-only let
s with the in_guaranteed convention.
#17047
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
@swift-ci Please smoke test |
@swift-ci Please test source compatibility |
Fixes rdar://problem/40828667. If we capture a `let` as inout_aliasable, then definite initialization mistakes capture of the `let` from a defer closure as an inappropriate inout use.
be494cf
to
f8b3541
Compare
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.
Looks good, just curious about the debuginfo change.
@@ -1925,8 +1925,12 @@ void IRGenDebugInfoImpl::emitVariableDeclaration( | |||
|
|||
// There are variables without storage, such as "struct { func foo() {} | |||
// }". Emit them as constant 0. | |||
if (isa<llvm::UndefValue>(Piece)) | |||
Piece = llvm::ConstantInt::get(IGM.Int64Ty, 0); | |||
if (isa<llvm::UndefValue>(Piece)) { |
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.
What was this change about?
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 existing behavior is broken for an undef
of any type that isn't 64 bits in size. I should break it out into its own commit.
Unfortunately this appears to cause a lot of downstream breakage in the optimizer I can't cleanly detangle. I might have to look for a more targeted fix for the DI regression. |
let
s with the in_guaranteed convention.let
s with the in_guaranteed convention.
Sema enforces that closures can't modify the let properties of their captured contexts, but we consider the capture argument to be @inout_aliasable at the SIL level. Add an exception to our normal handling so that this use is considered read-only. Fixes rdar://problem/40828667. A more principled solution would be to treat let captures as @in_guaranteed (see swiftlang#17047), but that unfortunately leads to breakage elsewhere in the optimizer.
Sema enforces that closures can't modify the let properties of their captured contexts, but we consider the capture argument to be @inout_aliasable at the SIL level. Add an exception to our normal handling so that this use is considered read-only. Fixes rdar://problem/40828667. A more principled solution would be to treat let captures as @in_guaranteed (see swiftlang#17047), but that unfortunately leads to breakage elsewhere in the optimizer.
Fixes rdar://problem/40828667. If we capture a
let
as inout_aliasable, then definite initialization mistakes capture of thelet
from a defer closure as an inappropriate inout use.