mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Arrange for closure bodies promoted by AllocBoxToStack to have their originals removed by MoveOnlyChecker.
This is an improvement of #67031 which avoids deleting the closure function body during AllocBoxToStack, which still breaks pass invariants by modifying functions other than the currently-analyzed function. As a function pass, AllocBoxToStack also doesn't really know with certainty whether the original closure function is unused after stack promotion or not. We still want to eliminate the original when it may contain invalid SIL for move-only values that rely on the escape analysis for correct semantics, so rather than mark the original function to be *ignored* during move-only checking, mark it to be *deleted* by move-only checking if the function is in fact unused at that point. If the marked function is still used, we let it pass through move-only checking normally, which may cause redundant diagnostics but is the right thing to do since code is still potentially using the closure with escaping semantics. We should rearrange things to make this situation impossible in the future. rdar://110675352
This commit is contained in:
@@ -1047,9 +1047,9 @@ specializeApplySite(SILOptFunctionBuilder &FuncBuilder, ApplySite Apply,
|
||||
ClonedFn = Cloner.getCloned();
|
||||
pass.T->addFunctionToPassManagerWorklist(ClonedFn, F);
|
||||
|
||||
// Set the moveonly ignore flag so we do not emit an error on the original
|
||||
// function even though it is still around.
|
||||
F->addSemanticsAttr(semantics::NO_MOVEONLY_DIAGNOSTICS);
|
||||
// Set the moveonly delete-if-unused flag so we do not emit an error on the
|
||||
// original once we promote all its current uses.
|
||||
F->addSemanticsAttr(semantics::MOVEONLY_DELETE_IF_UNUSED);
|
||||
|
||||
// If any of our promoted callee arg indices were originally noncopyable let
|
||||
// boxes, convert them from having escaping to having non-escaping
|
||||
|
||||
Reference in New Issue
Block a user