File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed
SwiftCompilerSources/Sources/Optimizer/FunctionPasses
test/SILOptimizer/lifetime_dependence Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -199,9 +199,16 @@ private struct DiagnoseDependence {
199199 if function. hasUnsafeNonEscapableResult {
200200 return . continueWalk
201201 }
202- // If the dependence scope is global, then it has immortal lifetime.
203- if case . global = dependence. scope {
202+ // Check for immortal lifetime.
203+ switch dependence. scope {
204+ case . global:
204205 return . continueWalk
206+ case let . unknown( value) :
207+ if value. type. isVoid {
208+ return . continueWalk
209+ }
210+ default :
211+ break
205212 }
206213 // Check that the parameter dependence for this result is the same
207214 // as the current dependence scope.
Original file line number Diff line number Diff line change @@ -106,6 +106,11 @@ public struct NEInt: ~Escapable {
106106 init ( owner: borrowing NCInt ) {
107107 self . i = owner. i
108108 }
109+
110+ @_lifetime ( immortal)
111+ init ( immortal i: Int ) {
112+ self . i = i
113+ }
109114}
110115
111116struct TestDeinitCallsAddressor : ~ Copyable, ~ Escapable {
@@ -228,3 +233,13 @@ class ClassStorage {
228233 _ = ne
229234 }
230235}
236+
237+ // =============================================================================
238+ // Immortal
239+ // =============================================================================
240+
241+ @_lifetime ( immortal)
242+ func testVoid( ) -> NEInt {
243+ let ne = NEInt ( immortal: 3 )
244+ return _overrideLifetime ( ne, borrowing: ( ) )
245+ }
You can’t perform that action at this time.
0 commit comments