Skip to content

Fix dead end block collection while completing lexical lifetimes #64990

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2023
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
2 changes: 1 addition & 1 deletion lib/SIL/Utils/OSSALifetimeCompletion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ static bool endLifetimeAtUnreachableBlocks(SILValue value,
changed = true;
}
for (auto *successor : block->getSuccessorBlocks()) {
deadEndBlocks.push(successor);
deadEndBlocks.pushIfNotVisited(successor);
}
}
return changed;
Expand Down
41 changes: 41 additions & 0 deletions test/SILOptimizer/ossa_lifetime_completion.sil
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,44 @@ bb3:
return %r : $()
}

// Ensure no assert fires while inserting dead end blocks to the worklist
sil [ossa] @testLexicalLifetimeCompletion : $@convention(thin) (@owned C) -> () {
bb0(%0 : @owned $C):
test_specification "ossa-lifetime-completion @argument"
debug_value %0 : $C, let, name "newElements", argno 1
cond_br undef, bb1, bb2

bb1:
cond_br undef, bb3, bb4

bb2:
cond_br undef, bb9, bb10

bb3:
br bb8

bb4:
cond_br undef, bb5, bb6

bb5:
br bb7

bb6:
br bb7

bb7:
unreachable

bb8:
%77 = apply undef(%0) : $@convention(method) (@guaranteed C) -> ()
destroy_value %0 : $C
%79 = tuple ()
return %79 : $()

bb9:
br bb8

bb10:
br bb8
}