Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/SIL/Utils/OwnershipUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1438,11 +1438,11 @@ void swift::findTransitiveReborrowBaseValuePairs(
void swift::visitTransitiveEndBorrows(
BorrowedValue beginBorrow,
function_ref<void(EndBorrowInst *)> visitEndBorrow) {
SmallSetVector<SILValue, 4> worklist;
DAGNodeWorklist<SILValue, 4> 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<BranchInst>(consumingUser)) {
Expand Down
27 changes: 27 additions & 0 deletions test/SILOptimizer/dead_code_elimination_nontrivial_ossa.sil
Original file line number Diff line number Diff line change
Expand Up @@ -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<Klass>, #FakeOptional.none!enumelt
%lifetime_1 = begin_borrow [lexical] %instance_1 : $FakeOptional<Klass>
br loop_entry(%instance_1 : $FakeOptional<Klass>, %lifetime_1 : $FakeOptional<Klass>)

loop_entry(%18 : @owned $FakeOptional<Klass>, %19 : @guaranteed $FakeOptional<Klass>):
br loop_body

loop_body:
cond_br undef, loop_back, loop_exit

loop_back:
br loop_entry(%18 : $FakeOptional<Klass>, %19 : $FakeOptional<Klass>)

loop_exit:
end_borrow %19 : $FakeOptional<Klass>
destroy_value %18 : $FakeOptional<Klass>
br exit

exit:
%retval = tuple ()
return %retval : $()
}