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(
4343 }
4444 }
4545 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
4961 }
5062 }
5163}
Original file line number Diff line number Diff line change @@ -174,6 +174,20 @@ extension LifetimeDependence {
174174 self . dependentValue = arg
175175 }
176176
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+
177191 /// Construct LifetimeDependence from mark_dependence [nonescaping]
178192 ///
179193 /// 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> {
75997599 }
76007600 sub->Printer << " ) -> " ;
76017601
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 () << " " ;
76057605 }
76067606
76077607 bool parenthesizeResults = mustParenthesizeResults (T);
You can’t perform that action at this time.
0 commit comments