@@ -53,12 +53,19 @@ class OSSALifetimeCompletion {
53
53
// / Insert a lifetime-ending instruction on every path to complete the OSSA
54
54
// / lifetime of \p value. Lifetime completion is only relevant for owned
55
55
// / values or borrow introducers.
56
- // /
56
+ // / For lexical values lifetime is completed at unreachable instructions.
57
+ // / For non-lexical values lifetime is completed at the lifetime boundary.
58
+ // / When \p forceBoundaryCompletion is true, the client is able to guarantee
59
+ // / that lifetime completion of lexical values at the lifetime boundary is
60
+ // / sufficient.
61
+ // / Currently \p forceBoundaryCompletion is used by mem2reg and temprvalueopt
62
+ // / to complete lexical enum values on trivial paths.
57
63
// / Returns true if any new instructions were created to complete the
58
64
// / lifetime.
59
65
// /
60
66
// / TODO: We also need to complete scoped addresses (e.g. store_borrow)!
61
- LifetimeCompletion completeOSSALifetime (SILValue value) {
67
+ LifetimeCompletion
68
+ completeOSSALifetime (SILValue value, bool forceBoundaryCompletion = false ) {
62
69
if (value->getOwnershipKind () == OwnershipKind::None)
63
70
return LifetimeCompletion::NoLifetime;
64
71
@@ -73,13 +80,13 @@ class OSSALifetimeCompletion {
73
80
if (!completedValues.insert (value))
74
81
return LifetimeCompletion::AlreadyComplete;
75
82
76
- return analyzeAndUpdateLifetime (value)
77
- ? LifetimeCompletion::WasCompleted
78
- : LifetimeCompletion::AlreadyComplete;
83
+ return analyzeAndUpdateLifetime (value, forceBoundaryCompletion )
84
+ ? LifetimeCompletion::WasCompleted
85
+ : LifetimeCompletion::AlreadyComplete;
79
86
}
80
87
81
88
protected:
82
- bool analyzeAndUpdateLifetime (SILValue value);
89
+ bool analyzeAndUpdateLifetime (SILValue value, bool forceBoundaryCompletion );
83
90
};
84
91
85
92
// ===----------------------------------------------------------------------===//
0 commit comments