Skip to content

[sil] Replace some nstances of SILBuilder(...) with SILBuilderWithSco… #23821

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
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/BasicBlockUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ SILBasicBlock *swift::splitEdge(TermInst *T, unsigned edgeIdx,
SmallVector<SILValue, 16> args;
getEdgeArgs(T, edgeIdx, edgeBB, args);

SILBuilder(edgeBB).createBranch(T->getLoc(), destBB, args);
SILBuilderWithScope(edgeBB, T).createBranch(T->getLoc(), destBB, args);

// Strip the arguments and rewire the branch in the source block.
changeBranchTarget(T, edgeIdx, edgeBB, /*PreserveArgs=*/false);
Expand Down
24 changes: 12 additions & 12 deletions lib/SILOptimizer/LoopTransforms/LoopUnroll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,18 +239,18 @@ static void redirectTerminator(SILBasicBlock *Latch, unsigned CurLoopIter,
auto *CondBr = cast<CondBranchInst>(
Latch->getSinglePredecessorBlock()->getTerminator());
if (CondBr->getTrueBB() != Latch)
SILBuilder(CondBr).createBranch(CondBr->getLoc(), CondBr->getTrueBB(),
CondBr->getTrueArgs());
SILBuilderWithScope(CondBr).createBranch(
CondBr->getLoc(), CondBr->getTrueBB(), CondBr->getTrueArgs());
else
SILBuilder(CondBr).createBranch(CondBr->getLoc(), CondBr->getFalseBB(),
CondBr->getFalseArgs());
SILBuilderWithScope(CondBr).createBranch(
CondBr->getLoc(), CondBr->getFalseBB(), CondBr->getFalseArgs());
CondBr->eraseFromParent();
return;
}

// Otherwise, branch to the next iteration's header.
SILBuilder(Br).createBranch(Br->getLoc(), NextIterationsHeader,
Br->getArgs());
SILBuilderWithScope(Br).createBranch(Br->getLoc(), NextIterationsHeader,
Br->getArgs());
Br->eraseFromParent();
return;
}
Expand All @@ -261,25 +261,25 @@ static void redirectTerminator(SILBasicBlock *Latch, unsigned CurLoopIter,
// one.
if (CurLoopIter == LastLoopIter) {
if (CondBr->getTrueBB() == CurrentHeader) {
SILBuilder(CondBr).createBranch(CondBr->getLoc(), CondBr->getFalseBB(),
CondBr->getFalseArgs());
SILBuilderWithScope(CondBr).createBranch(
CondBr->getLoc(), CondBr->getFalseBB(), CondBr->getFalseArgs());
} else {
assert(CondBr->getFalseBB() == CurrentHeader);
SILBuilder(CondBr).createBranch(CondBr->getLoc(), CondBr->getTrueBB(),
CondBr->getTrueArgs());
SILBuilderWithScope(CondBr).createBranch(
CondBr->getLoc(), CondBr->getTrueBB(), CondBr->getTrueArgs());
}
CondBr->eraseFromParent();
return;
}

// Otherwise, branch to the next iteration's header.
if (CondBr->getTrueBB() == CurrentHeader) {
SILBuilder(CondBr).createCondBranch(
SILBuilderWithScope(CondBr).createCondBranch(
CondBr->getLoc(), CondBr->getCondition(), NextIterationsHeader,
CondBr->getTrueArgs(), CondBr->getFalseBB(), CondBr->getFalseArgs());
} else {
assert(CondBr->getFalseBB() == CurrentHeader);
SILBuilder(CondBr).createCondBranch(
SILBuilderWithScope(CondBr).createCondBranch(
CondBr->getLoc(), CondBr->getCondition(), CondBr->getTrueBB(),
CondBr->getTrueArgs(), NextIterationsHeader, CondBr->getFalseArgs());
}
Expand Down
12 changes: 6 additions & 6 deletions lib/SILOptimizer/Utils/CheckedCastBrJumpThreading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ void CheckedCastBrJumpThreading::Edit::modifyCFGForUnknownPreds() {
if (auto *CMI = dyn_cast<ClassMethodInst>(Inst)) {
if (CMI->getOperand() == stripClassCasts(CCBI->getOperand())) {
// Replace checked_cast_br by branch to FailureBB.
SILBuilder(CCBI->getParent()).createBranch(CCBI->getLoc(),
CCBI->getFailureBB());
SILBuilderWithScope(CCBI).createBranch(CCBI->getLoc(),
CCBI->getFailureBB());
CCBI->eraseFromParent();
}
}
Expand Down Expand Up @@ -275,8 +275,8 @@ modifyCFGForSuccessPreds(Optional<BasicBlockCloner> &Cloner) {
auto *CCBI = cast<CheckedCastBranchInst>(CCBBlock->getTerminator());

if (InvertSuccess) {
SILBuilder B(CCBBlock);
B.createBranch(CCBI->getLoc(), CCBI->getFailureBB());
SILBuilderWithScope(CCBI).createBranch(CCBI->getLoc(),
CCBI->getFailureBB());
CCBI->eraseFromParent();
return;
}
Expand Down Expand Up @@ -313,8 +313,8 @@ modifyCFGForSuccessPreds(Optional<BasicBlockCloner> &Cloner) {

// Add an unconditional jump at the end of the block.
// Take argument value from the dominating BB
SILBuilder(CCBBlock).createBranch(CCBI->getLoc(), CCBI->getSuccessBB(),
{SuccessArg});
SILBuilderWithScope(CCBI).createBranch(CCBI->getLoc(), CCBI->getSuccessBB(),
{SuccessArg});
CCBI->eraseFromParent();
}

Expand Down