File tree Expand file tree Collapse file tree 3 files changed +32
-6
lines changed
SwiftCompilerSources/Sources/Optimizer Expand file tree Collapse file tree 3 files changed +32
-6
lines changed Original file line number Diff line number Diff line change @@ -43,9 +43,21 @@ let lifetimeDependenceDiagnosticsPass = FunctionPass(
43
43
}
44
44
}
45
45
for instruction in function. instructions {
46
- guard let markDep = instruction as? MarkDependenceInst else { continue }
47
- if let lifetimeDep = LifetimeDependence ( markDep, context) {
48
- analyze ( dependence: lifetimeDep, context)
46
+ if let markDep = instruction as? MarkDependenceInst {
47
+ if let lifetimeDep = LifetimeDependence ( markDep, context) {
48
+ analyze ( dependence: lifetimeDep, context)
49
+ }
50
+ continue
51
+ }
52
+ if let apply = instruction as? FullApplySite {
53
+ // Handle ~Escapable results that do not have a lifetime
54
+ // dependence (@_unsafeNonescapableResult).
55
+ apply. dependentValues. forEach {
56
+ if let lifetimeDep = LifetimeDependence ( applyResult: $0, context) {
57
+ analyze ( dependence: lifetimeDep, context)
58
+ }
59
+ }
60
+ continue
49
61
}
50
62
}
51
63
}
Original file line number Diff line number Diff line change @@ -174,6 +174,20 @@ extension LifetimeDependence {
174
174
self . dependentValue = arg
175
175
}
176
176
177
+ // Handle ~Escapable results that do not have a lifetime dependence
178
+ // (@_unsafeNonescapableResult).
179
+ init ? ( applyResult value: Value , _ context: some Context ) {
180
+ if value. type. isEscapable {
181
+ return nil
182
+ }
183
+ let applySite = value. definingInstruction as! FullApplySite
184
+ if applySite. calleeArgumentConventions. resultDependencies != nil {
185
+ return nil
186
+ }
187
+ self . scope = Scope ( base: value, context) !
188
+ self . dependentValue = value
189
+ }
190
+
177
191
/// Construct LifetimeDependence from mark_dependence [nonescaping]
178
192
///
179
193
/// TODO: Add SIL verification that all mark_depedence [nonescaping]
Original file line number Diff line number Diff line change @@ -7599,9 +7599,9 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
7599
7599
}
7600
7600
sub->Printer << " ) -> " ;
7601
7601
7602
- auto * lifetimeDependenceInfo = T->getLifetimeDependenceInfo ();
7603
- if (lifetimeDependenceInfo && !lifetimeDependenceInfo-> empty ()) {
7604
- sub->Printer << lifetimeDependenceInfo-> getString () << " " ;
7602
+ auto lifetimeDependenceInfo = T->getLifetimeDependenceInfo ();
7603
+ if (!lifetimeDependenceInfo. empty ()) {
7604
+ sub->Printer << lifetimeDependenceInfo. getString () << " " ;
7605
7605
}
7606
7606
7607
7607
bool parenthesizeResults = mustParenthesizeResults (T);
You can’t perform that action at this time.
0 commit comments