@@ -137,9 +137,21 @@ static void fixupReferenceCounts(
137
137
}
138
138
139
139
visitedBlocks.clear ();
140
+
140
141
// If we need to insert compensating destroys, do so.
142
+ //
143
+ // NOTE: We use pai here since in non-ossa code emitCopyValueOperation
144
+ // returns the operand of the strong_retain which may have a ValueBase
145
+ // that is not in the same block. An example of where this is important is
146
+ // if we are performing emitCopyValueOperation in non-ossa code on an
147
+ // argument when the partial_apply is not in the entrance block. In truth,
148
+ // the linear lifetime checker does not /actually/ care what the value is
149
+ // (ignoring diagnostic error msgs that we do not care about here), it
150
+ // just cares about the block the value is in. In a forthcoming commit, I
151
+ // am going to change this to use a different API on the linear lifetime
152
+ // checker that makes this clearer.
141
153
auto error =
142
- valueHasLinearLifetime (copy , {applySite}, {}, visitedBlocks,
154
+ valueHasLinearLifetime (pai , {applySite}, {}, visitedBlocks,
143
155
deadEndBlocks, errorBehavior, &leakingBlocks);
144
156
if (error.getFoundLeak ()) {
145
157
while (!leakingBlocks.empty ()) {
@@ -175,11 +187,22 @@ static void fixupReferenceCounts(
175
187
// TODO: Do we need to lifetime extend here?
176
188
case ParameterConvention::Direct_Unowned: {
177
189
v = SILBuilderWithScope (pai).emitCopyValueOperation (loc, v);
178
-
179
190
visitedBlocks.clear ();
191
+
180
192
// If we need to insert compensating destroys, do so.
193
+ //
194
+ // NOTE: We use pai here since in non-ossa code emitCopyValueOperation
195
+ // returns the operand of the strong_retain which may have a ValueBase
196
+ // that is not in the same block. An example of where this is important is
197
+ // if we are performing emitCopyValueOperation in non-ossa code on an
198
+ // argument when the partial_apply is not in the entrance block. In truth,
199
+ // the linear lifetime checker does not /actually/ care what the value is
200
+ // (ignoring diagnostic error msgs that we do not care about here), it
201
+ // just cares about the block the value is in. In a forthcoming commit, I
202
+ // am going to change this to use a different API on the linear lifetime
203
+ // checker that makes this clearer.
181
204
auto error =
182
- valueHasLinearLifetime (v , {applySite}, {}, visitedBlocks,
205
+ valueHasLinearLifetime (pai , {applySite}, {}, visitedBlocks,
183
206
deadEndBlocks, errorBehavior, &leakingBlocks);
184
207
if (error.getFoundError ()) {
185
208
while (!leakingBlocks.empty ()) {
@@ -203,11 +226,22 @@ static void fixupReferenceCounts(
203
226
// apply has another use that would destroy our value first.
204
227
case ParameterConvention::Direct_Owned: {
205
228
v = SILBuilderWithScope (pai).emitCopyValueOperation (loc, v);
206
-
207
229
visitedBlocks.clear ();
230
+
208
231
// If we need to insert compensating destroys, do so.
232
+ //
233
+ // NOTE: We use pai here since in non-ossa code emitCopyValueOperation
234
+ // returns the operand of the strong_retain which may have a ValueBase
235
+ // that is not in the same block. An example of where this is important is
236
+ // if we are performing emitCopyValueOperation in non-ossa code on an
237
+ // argument when the partial_apply is not in the entrance block. In truth,
238
+ // the linear lifetime checker does not /actually/ care what the value is
239
+ // (ignoring diagnostic error msgs that we do not care about here), it
240
+ // just cares about the block the value is in. In a forthcoming commit, I
241
+ // am going to change this to use a different API on the linear lifetime
242
+ // checker that makes this clearer.
209
243
auto error =
210
- valueHasLinearLifetime (v , {applySite}, {}, visitedBlocks,
244
+ valueHasLinearLifetime (pai , {applySite}, {}, visitedBlocks,
211
245
deadEndBlocks, errorBehavior, &leakingBlocks);
212
246
if (error.getFoundError ()) {
213
247
while (!leakingBlocks.empty ()) {
0 commit comments