@@ -45,13 +45,23 @@ let lifetimeDependenceDiagnosticsPass = FunctionPass(
45
45
// Indirect results are not checked here. Type checking ensures
46
46
// that they have a lifetime dependence.
47
47
if let lifetimeDep = LifetimeDependence ( argument, context) {
48
- analyze ( dependence: lifetimeDep, context)
48
+ _ = analyze ( dependence: lifetimeDep, context)
49
49
}
50
50
}
51
51
for instruction in function. instructions {
52
52
if let markDep = instruction as? MarkDependenceInst , markDep. isUnresolved {
53
53
if let lifetimeDep = LifetimeDependence ( markDep, context) {
54
- analyze ( dependence: lifetimeDep, context)
54
+ if analyze ( dependence: lifetimeDep, context) {
55
+ // Note: This promotes the mark_dependence flag but does not invalidate SIL; preserving analyses is good,
56
+ // but the change won't appear in -sil-print-function. Ideally, we could notify context of a flag change
57
+ // without invalidating analyses.
58
+ lifetimeDep. resolve ( context)
59
+ }
60
+ } else {
61
+ // For now, if the mark_dependence wasn't recognized as a lifetime dependence, conservatively settle it as
62
+ // escaping. In the future, we should not need this because, for escapable types, mark_dependence [unresolved]
63
+ // will all be settled during an early LifetimeNormalization pass.
64
+ markDep. settleToEscaping ( )
55
65
}
56
66
continue
57
67
}
@@ -61,7 +71,7 @@ let lifetimeDependenceDiagnosticsPass = FunctionPass(
61
71
apply. resultOrYields. forEach {
62
72
if let lifetimeDep = LifetimeDependence ( unsafeApplyResult: $0,
63
73
context) {
64
- analyze ( dependence: lifetimeDep, context)
74
+ _ = analyze ( dependence: lifetimeDep, context)
65
75
}
66
76
}
67
77
continue
@@ -74,8 +84,9 @@ let lifetimeDependenceDiagnosticsPass = FunctionPass(
74
84
/// 1. Compute the LifetimeDependence scope.
75
85
///
76
86
/// 2. Walk down all dependent values checking that they are within range.
77
- private func analyze( dependence: LifetimeDependence ,
78
- _ context: FunctionPassContext ) {
87
+ ///
88
+ /// Return true on success.
89
+ private func analyze( dependence: LifetimeDependence , _ context: FunctionPassContext ) -> Bool {
79
90
log ( " Dependence scope: \n \( dependence) " )
80
91
81
92
// Compute this dependence scope.
@@ -91,10 +102,7 @@ private func analyze(dependence: LifetimeDependence,
91
102
var walker = DiagnoseDependenceWalker ( diagnostics, context)
92
103
defer { walker. deinitialize ( ) }
93
104
_ = walker. walkDown ( root: dependence. dependentValue)
94
-
95
- if !error {
96
- dependence. resolve ( context)
97
- }
105
+ return !error
98
106
}
99
107
100
108
/// Analyze and diagnose a single LifetimeDependence.
0 commit comments