Skip to content

Commit 646cf23

Browse files
committed
[AddressLowering] Handle fix_lifetime.
1 parent 639f318 commit 646cf23

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

lib/SILOptimizer/Mandatory/AddressLowering.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2651,6 +2651,13 @@ class UseRewriter : SILInstructionVisitor<UseRewriter> {
26512651

26522652
void visitEndBorrowInst(EndBorrowInst *end) {}
26532653

2654+
void visitFixLifetimeInst(FixLifetimeInst *fli) {
2655+
SILValue value = fli->getOperand();
2656+
SILValue address = pass.valueStorageMap.getStorage(value).storageAddress;
2657+
builder.createFixLifetime(fli->getLoc(), address);
2658+
pass.deleter.forceDelete(fli);
2659+
}
2660+
26542661
void visitBranchInst(BranchInst *) {
26552662
pass.getPhiRewriter().materializeOperand(use);
26562663

test/SILOptimizer/address_lowering.sil

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,6 +1228,18 @@ bb2(%9 : $Error):
12281228
throw %9 : $Error
12291229
}
12301230

1231+
// CHECK-LABEL: sil [ossa] @fixeeLifetime : {{.*}} {
1232+
// CHECK: {{bb[0-9]+}}([[ADDR:%[^,]+]] : $*T):
1233+
// CHECK: fix_lifetime [[ADDR]]
1234+
// CHECK-LABEL: } // end sil function 'fixeeLifetime'
1235+
sil [ossa] @fixeeLifetime : $@convention(thin) <T> (@in T) -> () {
1236+
bb0(%instance : @owned $T):
1237+
fix_lifetime %instance : $T
1238+
destroy_value %instance : $T
1239+
%retval = tuple ()
1240+
return %retval : $()
1241+
}
1242+
12311243
// CHECK-LABEL: sil [ossa] @lexical_borrow_struct_extract {{.*}} {
12321244
// CHECK: [[PAIR_ADDR:%[^,]+]] = alloc_stack [lexical]
12331245
// CHECK: [[X_ADDR:%[^,]+]] = struct_element_addr [[PAIR_ADDR]]

0 commit comments

Comments
 (0)