File tree Expand file tree Collapse file tree 3 files changed +25
-3
lines changed
SwiftCompilerSources/Sources/Optimizer
test/SILOptimizer/lifetime_dependence Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -199,9 +199,16 @@ private struct DiagnoseDependence {
199
199
if function. hasUnsafeNonEscapableResult {
200
200
return . continueWalk
201
201
}
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:
204
205
return . continueWalk
206
+ case let . unknown( value) :
207
+ if value. type. isVoid {
208
+ return . continueWalk
209
+ }
210
+ default :
211
+ break
205
212
}
206
213
// Check that the parameter dependence for this result is the same
207
214
// as the current dependence scope.
Original file line number Diff line number Diff line change @@ -118,7 +118,7 @@ extension ForwardingUseDefWalker {
118
118
}
119
119
mutating func walkUpDefault( forwarded value: Value , _ path: PathContext )
120
120
-> WalkResult {
121
- if let inst = value. forwardingInstruction {
121
+ if let inst = value. forwardingInstruction, !inst . forwardedOperands . isEmpty {
122
122
return walkUp ( instruction: inst, path)
123
123
}
124
124
if let phi = Phi ( value) {
Original file line number Diff line number Diff line change @@ -106,6 +106,11 @@ public struct NEInt: ~Escapable {
106
106
init ( owner: borrowing NCInt ) {
107
107
self . i = owner. i
108
108
}
109
+
110
+ @_lifetime ( immortal)
111
+ init ( immortal i: Int ) {
112
+ self . i = i
113
+ }
109
114
}
110
115
111
116
struct TestDeinitCallsAddressor : ~ Copyable, ~ Escapable {
@@ -228,3 +233,13 @@ class ClassStorage {
228
233
_ = ne
229
234
}
230
235
}
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