@@ -168,21 +168,14 @@ class AvailabilityBoundaryVisitor {
168
168
// / The value whose dead-end block lifetime ends are to be visited.
169
169
SILValue value;
170
170
171
- // / Whether to allow leaks.
172
- // /
173
- // / Here, that entails allowing walks to reach non-unreachable terminators and
174
- // / not creating lifetime ends before them.
175
- OSSALifetimeCompletion::AllowLeaks_t allowLeaks;
176
-
177
171
// / The non-lifetime-ending boundary of `value`.
178
172
BasicBlockSet starts;
179
173
// / The region between (inclusive) the `starts` and the unreachable blocks.
180
174
BasicBlockSetVector region;
181
175
182
176
public:
183
- AvailabilityBoundaryVisitor (SILValue value,
184
- OSSALifetimeCompletion::AllowLeaks_t allowLeaks)
185
- : value(value), allowLeaks(allowLeaks), starts(value->getFunction ()),
177
+ AvailabilityBoundaryVisitor (SILValue value)
178
+ : value(value), starts(value->getFunction ()),
186
179
region(value->getFunction ()) {}
187
180
188
181
using Visit = llvm::function_ref<void (SILInstruction *,
@@ -307,10 +300,7 @@ void AvailabilityBoundaryVisitor::computeRegion(
307
300
// Thus finding a value available at the end of such a block means that
308
301
// the block does _not_ must not exits the function normally; in other
309
302
// words its terminator must be an UnreachableInst.
310
- //
311
- // In invalid OSSA, indicated by the `allowLeaks` flag, no such guarantee
312
- // exists.
313
- assert (isa<UnreachableInst>(block->getTerminator ()) || allowLeaks);
303
+ assert (isa<UnreachableInst>(block->getTerminator ()));
314
304
}
315
305
for (auto *successor : block->getSuccessorBlocks ()) {
316
306
regionWorklist.pushIfNotVisited (successor);
@@ -379,12 +369,6 @@ void AvailabilityBoundaryVisitor::visitAvailabilityBoundary(
379
369
if (!block->succ_empty () && !hasUnavailableSuccessor ()) {
380
370
continue ;
381
371
}
382
- if (allowLeaks && block->succ_empty () &&
383
- !isa<UnreachableInst>(block->getTerminator ())) {
384
- // Availability extends to the end of a function-exiting-normally block.
385
- // If leaks are allowed, don't visit.
386
- continue ;
387
- }
388
372
assert (hasUnavailableSuccessor () ||
389
373
isa<UnreachableInst>(block->getTerminator ()));
390
374
visit (block->getTerminator (),
@@ -394,10 +378,10 @@ void AvailabilityBoundaryVisitor::visitAvailabilityBoundary(
394
378
} // end anonymous namespace
395
379
396
380
void OSSALifetimeCompletion::visitAvailabilityBoundary (
397
- SILValue value, AllowLeaks_t allowLeaks, const SSAPrunedLiveness &liveness,
381
+ SILValue value, const SSAPrunedLiveness &liveness,
398
382
llvm::function_ref<void (SILInstruction *, LifetimeEnd end)> visit) {
399
383
400
- AvailabilityBoundaryVisitor visitor (value, allowLeaks );
384
+ AvailabilityBoundaryVisitor visitor (value);
401
385
AvailabilityBoundaryVisitor::Result result (value->getFunction ());
402
386
visitor.visit (liveness, result, visit);
403
387
@@ -410,12 +394,12 @@ void OSSALifetimeCompletion::visitAvailabilityBoundary(
410
394
});
411
395
}
412
396
413
- static bool endLifetimeAtAvailabilityBoundary (
414
- SILValue value, OSSALifetimeCompletion::AllowLeaks_t allowLeaks ,
415
- const SSAPrunedLiveness &liveness) {
397
+ static bool
398
+ endLifetimeAtAvailabilityBoundary ( SILValue value,
399
+ const SSAPrunedLiveness &liveness) {
416
400
bool changed = false ;
417
401
OSSALifetimeCompletion::visitAvailabilityBoundary (
418
- value, allowLeaks, liveness, [&](auto *unreachable, auto end) {
402
+ value, liveness, [&](auto *unreachable, auto end) {
419
403
SILBuilderWithScope builder (unreachable);
420
404
endOSSALifetime (value, end, builder);
421
405
changed = true ;
@@ -442,12 +426,7 @@ bool OSSALifetimeCompletion::analyzeAndUpdateLifetime(SILValue value,
442
426
changed |= endLifetimeAtLivenessBoundary (value, liveness.getLiveness ());
443
427
break ;
444
428
case Boundary::Availability:
445
- changed |= endLifetimeAtAvailabilityBoundary (value, DoNotAllowLeaks,
446
- liveness.getLiveness ());
447
- break ;
448
- case Boundary::AvailabilityWithLeaks:
449
- changed |= endLifetimeAtAvailabilityBoundary (value, AllowLeaks,
450
- liveness.getLiveness ());
429
+ changed |= endLifetimeAtAvailabilityBoundary (value, liveness.getLiveness ());
451
430
break ;
452
431
}
453
432
// TODO: Rebuild outer adjacent phis on demand (SILGen does not currently
@@ -472,9 +451,7 @@ static FunctionTest OSSALifetimeCompletionTest(
472
451
arguments.takeString ())
473
452
.Case (" liveness" , OSSALifetimeCompletion::Boundary::Liveness)
474
453
.Case (" availability" ,
475
- OSSALifetimeCompletion::Boundary::Availability)
476
- .Case (" availability_with_leaks" ,
477
- OSSALifetimeCompletion::Boundary::AvailabilityWithLeaks);
454
+ OSSALifetimeCompletion::Boundary::Availability);
478
455
llvm::outs () << " OSSA lifetime completion on " << kind
479
456
<< " boundary: " << value;
480
457
OSSALifetimeCompletion completion (&function, /* domInfo*/ nullptr );
0 commit comments