Skip to content

[gardening] Eliminate passing around of SILBuilders. #30350

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
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
9 changes: 4 additions & 5 deletions lib/SILOptimizer/Utils/Generics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1939,8 +1939,8 @@ static void prepareCallArguments(ApplySite AI, SILBuilder &Builder,
/// function being applied.
static ApplySite replaceWithSpecializedCallee(ApplySite AI,
SILValue Callee,
SILBuilder &Builder,
const ReabstractionInfo &ReInfo) {
SILBuilderWithScope Builder(AI.getInstruction());
SILLocation Loc = AI.getLoc();
SmallVector<SILValue, 4> Arguments;
SILValue StoreResultTo;
Expand Down Expand Up @@ -2029,7 +2029,7 @@ replaceWithSpecializedFunction(ApplySite AI, SILFunction *NewF,
const ReabstractionInfo &ReInfo) {
SILBuilderWithScope Builder(AI.getInstruction());
FunctionRefInst *FRI = Builder.createFunctionRef(AI.getLoc(), NewF);
return replaceWithSpecializedCallee(AI, FRI, Builder, ReInfo);
return replaceWithSpecializedCallee(AI, FRI, ReInfo);
}

namespace {
Expand Down Expand Up @@ -2444,11 +2444,11 @@ void swift::trySpecializeApplyOfGeneric(
// thunk which converts from the re-abstracted function back to the
// original function with indirect parameters/results.
auto *PAI = cast<PartialApplyInst>(Apply.getInstruction());
SILBuilderWithScope Builder(PAI);
SILFunction *Thunk =
ReabstractionThunkGenerator(FuncBuilder, ReInfo, PAI, SpecializedF)
.createThunk();
NewFunctions.push_back(Thunk);
SILBuilderWithScope Builder(PAI);
auto *FRI = Builder.createFunctionRef(PAI->getLoc(), Thunk);
SmallVector<SILValue, 4> Arguments;
for (auto &Op : PAI->getArgumentOperands()) {
Expand Down Expand Up @@ -2476,8 +2476,7 @@ void swift::trySpecializeApplyOfGeneric(
for (Operand *Use : NewPAI->getUses()) {
SILInstruction *User = Use->getUser();
if (auto FAS = FullApplySite::isa(User)) {
SILBuilder Builder(User);
replaceWithSpecializedCallee(FAS, NewPAI, Builder, ReInfo);
replaceWithSpecializedCallee(FAS, NewPAI, ReInfo);
DeadApplies.insert(FAS.getInstruction());
continue;
}
Expand Down