@@ -168,21 +168,14 @@ class AvailabilityBoundaryVisitor {
168168 // / The value whose dead-end block lifetime ends are to be visited.
169169 SILValue value;
170170
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-
177171 // / The non-lifetime-ending boundary of `value`.
178172 BasicBlockSet starts;
179173 // / The region between (inclusive) the `starts` and the unreachable blocks.
180174 BasicBlockSetVector region;
181175
182176public:
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 ()),
186179 region(value->getFunction ()) {}
187180
188181 using Visit = llvm::function_ref<void (SILInstruction *,
@@ -307,10 +300,7 @@ void AvailabilityBoundaryVisitor::computeRegion(
307300 // Thus finding a value available at the end of such a block means that
308301 // the block does _not_ must not exits the function normally; in other
309302 // 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 ()));
314304 }
315305 for (auto *successor : block->getSuccessorBlocks ()) {
316306 regionWorklist.pushIfNotVisited (successor);
@@ -379,12 +369,6 @@ void AvailabilityBoundaryVisitor::visitAvailabilityBoundary(
379369 if (!block->succ_empty () && !hasUnavailableSuccessor ()) {
380370 continue ;
381371 }
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- }
388372 assert (hasUnavailableSuccessor () ||
389373 isa<UnreachableInst>(block->getTerminator ()));
390374 visit (block->getTerminator (),
@@ -394,10 +378,10 @@ void AvailabilityBoundaryVisitor::visitAvailabilityBoundary(
394378} // end anonymous namespace
395379
396380void OSSALifetimeCompletion::visitAvailabilityBoundary (
397- SILValue value, AllowLeaks_t allowLeaks, const SSAPrunedLiveness &liveness,
381+ SILValue value, const SSAPrunedLiveness &liveness,
398382 llvm::function_ref<void (SILInstruction *, LifetimeEnd end)> visit) {
399383
400- AvailabilityBoundaryVisitor visitor (value, allowLeaks );
384+ AvailabilityBoundaryVisitor visitor (value);
401385 AvailabilityBoundaryVisitor::Result result (value->getFunction ());
402386 visitor.visit (liveness, result, visit);
403387
@@ -410,12 +394,12 @@ void OSSALifetimeCompletion::visitAvailabilityBoundary(
410394 });
411395}
412396
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) {
416400 bool changed = false ;
417401 OSSALifetimeCompletion::visitAvailabilityBoundary (
418- value, allowLeaks, liveness, [&](auto *unreachable, auto end) {
402+ value, liveness, [&](auto *unreachable, auto end) {
419403 SILBuilderWithScope builder (unreachable);
420404 endOSSALifetime (value, end, builder);
421405 changed = true ;
@@ -442,12 +426,7 @@ bool OSSALifetimeCompletion::analyzeAndUpdateLifetime(SILValue value,
442426 changed |= endLifetimeAtLivenessBoundary (value, liveness.getLiveness ());
443427 break ;
444428 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 ());
451430 break ;
452431 }
453432 // TODO: Rebuild outer adjacent phis on demand (SILGen does not currently
@@ -472,9 +451,7 @@ static FunctionTest OSSALifetimeCompletionTest(
472451 arguments.takeString ())
473452 .Case (" liveness" , OSSALifetimeCompletion::Boundary::Liveness)
474453 .Case (" availability" ,
475- OSSALifetimeCompletion::Boundary::Availability)
476- .Case (" availability_with_leaks" ,
477- OSSALifetimeCompletion::Boundary::AvailabilityWithLeaks);
454+ OSSALifetimeCompletion::Boundary::Availability);
478455 llvm::outs () << " OSSA lifetime completion on " << kind
479456 << " boundary: " << value;
480457 OSSALifetimeCompletion completion (&function, /* domInfo*/ nullptr );
0 commit comments