mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
ClosureLifetimeFixup: Remove copy of borrowed move-only nonescaping captures when possible.
SILGen introduces a copy of the capture, because the semantics of escaping partial_apply's requires the closure to take ownership of the parameters. We don't know when a closure is strictly nonescaping or its final lifetime until ClosureLifetimeFixup runs, but that replaces the consume of the copy with a borrow of the copy normally, hoping later passes fix it up. We can't wait that long for move-only types, which can't be copied, so try to remove the copy up front when the copy lives long enough and has no interfering uses other than the partial_apply. rdar://110137169
This commit is contained in:
@@ -289,7 +289,9 @@ void insertDestroyOfCapturedArguments(
|
||||
SILLocation loc = RegularLocation::getAutoGeneratedLocation());
|
||||
|
||||
void insertDeallocOfCapturedArguments(PartialApplyInst *pai,
|
||||
DominanceInfo *domInfo);
|
||||
DominanceInfo *domInfo,
|
||||
llvm::function_ref<bool(SILValue)> shouldInsertDestroy =
|
||||
[](SILValue arg) -> bool { return true; });
|
||||
|
||||
/// This iterator 'looks through' one level of builtin expect users exposing all
|
||||
/// users of the looked through builtin expect instruction i.e it presents a
|
||||
|
||||
Reference in New Issue
Block a user