diff --git a/lib/SIL/Utils/OwnershipUtils.cpp b/lib/SIL/Utils/OwnershipUtils.cpp index 15431c7e2ea76..75c6fbdcdcb5b 100644 --- a/lib/SIL/Utils/OwnershipUtils.cpp +++ b/lib/SIL/Utils/OwnershipUtils.cpp @@ -1438,11 +1438,11 @@ void swift::findTransitiveReborrowBaseValuePairs( void swift::visitTransitiveEndBorrows( BorrowedValue beginBorrow, function_ref visitEndBorrow) { - SmallSetVector worklist; + DAGNodeWorklist worklist; worklist.insert(beginBorrow.value); while (!worklist.empty()) { - auto val = worklist.pop_back_val(); + auto val = worklist.pop(); for (auto *consumingUse : val->getConsumingUses()) { auto *consumingUser = consumingUse->getUser(); if (auto *branch = dyn_cast(consumingUser)) { diff --git a/test/SILOptimizer/dead_code_elimination_nontrivial_ossa.sil b/test/SILOptimizer/dead_code_elimination_nontrivial_ossa.sil index 6e37fa0939560..13915e9ef680a 100644 --- a/test/SILOptimizer/dead_code_elimination_nontrivial_ossa.sil +++ b/test/SILOptimizer/dead_code_elimination_nontrivial_ossa.sil @@ -652,3 +652,30 @@ bb4(%3 : @owned $Klass): return %res : $() } +// CHECK-LABEL: sil [ossa] @looping_borrow : $@convention(thin) () -> () { +// CHECK-NOT: destroy_value +// CHECK-LABEL: } // end sil function 'looping_borrow' +sil [ossa] @looping_borrow : $@convention(thin) () -> () { +entry: + %instance_1 = enum $FakeOptional, #FakeOptional.none!enumelt + %lifetime_1 = begin_borrow [lexical] %instance_1 : $FakeOptional + br loop_entry(%instance_1 : $FakeOptional, %lifetime_1 : $FakeOptional) + +loop_entry(%18 : @owned $FakeOptional, %19 : @guaranteed $FakeOptional): + br loop_body + +loop_body: + cond_br undef, loop_back, loop_exit + +loop_back: + br loop_entry(%18 : $FakeOptional, %19 : $FakeOptional) + +loop_exit: + end_borrow %19 : $FakeOptional + destroy_value %18 : $FakeOptional + br exit + +exit: + %retval = tuple () + return %retval : $() +}