Skip to content

Commit c4a393c

Browse files
committed
[AddressLowering] Handle mark_unresolved... inst.
In the fullness of time, AddressLowering should never see such instructions because they will be eliminated after diagnostics. Until that time, though they need to be handled.
1 parent 6cdab78 commit c4a393c

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

lib/SILOptimizer/Mandatory/AddressLowering.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,9 @@ static Operand *getProjectedDefOperand(SILValue value) {
947947

948948
return nullptr;
949949

950+
case ValueKind::MarkUnresolvedNonCopyableValueInst:
951+
return &cast<MarkUnresolvedNonCopyableValueInst>(value)->getOperandRef();
952+
950953
case ValueKind::MoveValueInst:
951954
return &cast<MoveValueInst>(value)->getOperandRef();
952955

@@ -3480,6 +3483,16 @@ class UseRewriter : SILInstructionVisitor<UseRewriter> {
34803483
// types.
34813484
void visitOpenExistentialValueInst(OpenExistentialValueInst *openExistential);
34823485

3486+
void visitMarkUnresolvedNonCopyableValueInst(
3487+
MarkUnresolvedNonCopyableValueInst *inst) {
3488+
assert(use == getProjectedDefOperand(inst));
3489+
3490+
auto address = pass.valueStorageMap.getStorage(use->get()).storageAddress;
3491+
auto *replacement = builder.createMarkUnresolvedNonCopyableValueInst(
3492+
inst->getLoc(), address, inst->getCheckKind());
3493+
markRewritten(inst, replacement);
3494+
}
3495+
34833496
void visitMoveValueInst(MoveValueInst *mvi);
34843497

34853498
void visitReturnInst(ReturnInst *returnInst) {

test/SILOptimizer/address_lowering.sil

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2526,6 +2526,32 @@ bb0:
25262526
return %retval : $()
25272527
}
25282528

2529+
// CHECK-LABEL: sil [ossa] @test_mark_unresolved_non_copyable_value_1_consumable_and_assignable : {{.*}} {
2530+
// CHECK: bb0([[T:%[^,]+]] :
2531+
// CHECK: [[TP:%[^,]+]] = mark_unresolved_non_copyable_value [consumable_and_assignable] [[T]]
2532+
// CHECK: destroy_addr [[TP]]
2533+
// CHECK-LABEL: } // end sil function 'test_mark_unresolved_non_copyable_value_1_consumable_and_assignable'
2534+
sil [ossa] @test_mark_unresolved_non_copyable_value_1_consumable_and_assignable : $@convention(thin) <T> (@in @moveOnly T) -> () {
2535+
entry(%t : @owned $@moveOnly T):
2536+
%tp = mark_unresolved_non_copyable_value [consumable_and_assignable] %t : $@moveOnly T
2537+
destroy_value %tp : $@moveOnly T
2538+
%retval = tuple ()
2539+
return %retval : $()
2540+
}
2541+
2542+
// CHECK-LABEL: sil [ossa] @test_mark_unresolved_non_copyable_value_2_no_consume_or_assign : {{.*}} {
2543+
// CHECK: bb0([[T:%[^,]+]] :
2544+
// CHECK: [[TP:%[^,]+]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[T]]
2545+
// CHECK: destroy_addr [[TP]]
2546+
// CHECK-LABEL: } // end sil function 'test_mark_unresolved_non_copyable_value_2_no_consume_or_assign'
2547+
sil [ossa] @test_mark_unresolved_non_copyable_value_2_no_consume_or_assign : $@convention(thin) <T> (@in @moveOnly T) -> () {
2548+
entry(%t : @owned $@moveOnly T):
2549+
%tp = mark_unresolved_non_copyable_value [no_consume_or_assign] %t : $@moveOnly T
2550+
destroy_value %tp : $@moveOnly T
2551+
%retval = tuple ()
2552+
return %retval : $()
2553+
}
2554+
25292555
// CHECK-LABEL: sil [ossa] @test_open_pack_element_dominance : $@convention(thin) <each T> (@pack_guaranteed Pack{repeat each T}, Builtin.Word) -> () {
25302556
// CHECK: bb0([[PACK:%[^,]+]] :
25312557
// CHECK-SAME: [[RAW_INDEX:%[^,]+]] :

0 commit comments

Comments
 (0)