Skip to content

[simplify-cfg] Only check if we can remove releases by performing simple jump threading if our block argument is not a trivial type. #36167

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
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
8 changes: 5 additions & 3 deletions lib/SILOptimizer/Transforms/SimplifyCFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1058,18 +1058,20 @@ bool SimplifyCFG::tryJumpThreading(BranchInst *BI) {
// given the duplication.
int ThreadingBudget = 0;

for (unsigned i = 0, e = BI->getArgs().size(); i != e; ++i) {
for (unsigned i : indices(BI->getArgs())) {
SILValue Arg = BI->getArg(i);

// If the value being substituted on is release there is a chance we could
// remove the release after jump threading.
if (couldRemoveRelease(SrcBB, BI->getArg(i), DestBB,
if (!Arg->getType().isTrivial(*SrcBB->getParent()) &&
couldRemoveRelease(SrcBB, Arg, DestBB,
DestBB->getArgument(i))) {
ThreadingBudget = 8;
break;
}

// If the value being substituted is an enum, check to see if there are any
// switches on it.
SILValue Arg = BI->getArg(i);
if (!getEnumCase(Arg, BI->getParent()) &&
!isa<IntegerLiteralInst>(Arg))
continue;
Expand Down