Skip to content

Commit bff7618

Browse files
committed
[MoveChecker] Don't add defs to liveness.
When extending liveness, the instructions prior to a preexisting destroy are added to liveness. If that prior instruction is the def, adding it to liveness results in multi-def liveness understanding that there is a prior def. Fixes a bug exposed by adding coroutine ends to liveness rather than function ends.
1 parent c06d5db commit bff7618

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/SILOptimizer/Mandatory/MoveOnlyAddressCheckerUtils.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3436,8 +3436,11 @@ bool ExtendUnconsumedLiveness::hasDefAfter(SILInstruction *start,
34363436

34373437
void ExtendUnconsumedLiveness::addPreviousInstructionToLiveness(
34383438
SILInstruction *inst, unsigned element) {
3439-
auto range = TypeTreeLeafTypeRange(element, element + 1);
34403439
inst->visitPriorInstructions([&](auto *prior) {
3440+
if (liveness.isDef(prior, element)) {
3441+
return true;
3442+
}
3443+
auto range = TypeTreeLeafTypeRange(element, element + 1);
34413444
liveness.extendToNonUse(prior, range);
34423445
return true;
34433446
});

test/SILOptimizer/moveonly_addresschecker.sil

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,3 +859,15 @@ bb0(%0 : @guaranteed $NonTrivialStruct):
859859
%9999 = tuple ()
860860
return %9999 : $()
861861
}
862+
863+
sil [ossa] @f : $@convention(thin) (@inout NonTrivialStruct, @owned NonTrivialStruct) -> () {
864+
entry(%out : $*NonTrivialStruct, %s : @owned $NonTrivialStruct):
865+
%munc = mark_unresolved_non_copyable_value [consumable_and_assignable] %out : $*NonTrivialStruct
866+
br body
867+
body:
868+
store %s to [assign] %munc : $*NonTrivialStruct
869+
br exit
870+
exit:
871+
%retval = tuple ()
872+
return %retval : $()
873+
}

0 commit comments

Comments
 (0)