Skip to content

Commit f132379

Browse files
authored
Handle end_lifetime in SILInstruction::mayRelease (swiftlang#38841)
1 parent 2c6d762 commit f132379

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/SIL/IR/SILInstruction.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,6 +1129,7 @@ bool SILInstruction::mayRelease() const {
11291129
default:
11301130
llvm_unreachable("Unhandled releasing instruction!");
11311131

1132+
case SILInstructionKind::EndLifetimeInst:
11321133
case SILInstructionKind::GetAsyncContinuationInst:
11331134
case SILInstructionKind::GetAsyncContinuationAddrInst:
11341135
case SILInstructionKind::AwaitAsyncContinuationInst:

test/SILOptimizer/access_enforcement_opts_ossa.sil

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,3 +1817,18 @@ bb0(%0 : @guaranteed $Klass, %1 : $*Int64):
18171817
return %14 : $Builtin.NativeObject
18181818
}
18191819

1820+
class Bar {
1821+
func foo()
1822+
}
1823+
1824+
sil [ossa] @$testEndLifetime : $@convention(method) (@owned Bar, @in Bar) -> () {
1825+
bb0(%0 : @owned $Bar, %1 : $*Bar):
1826+
%b = begin_access [modify] [dynamic] %1 : $*Bar
1827+
end_access %b : $*Bar
1828+
%f = objc_method %0 : $Bar, #Bar.foo!foreign : (Bar) -> () -> (), $@convention(objc_method) (Bar) -> ()
1829+
%c = apply %f(%0) : $@convention(objc_method) (Bar) -> ()
1830+
end_lifetime %0 : $Bar
1831+
destroy_addr %1 : $*Bar
1832+
%r = tuple ()
1833+
return %r : $()
1834+
}

0 commit comments

Comments
 (0)