Skip to content

Commit 39f1767

Browse files
author
Jason Mittertreiner
committed
Fix SILInliner Compilation on MSVC
SILBuilder contains a SILBuilderContext which contains a SILModule which has a deleted operator=. Assigning an Optional<BeginApplySite> causes MSVC to attempt to create operator= for SILBuilder which fails due to the deleted operator=. This changes BeginApplySite to use a SILBuilder* instead of a SILBuilder& to get around it.
1 parent eac1524 commit 39f1767

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

lib/SILOptimizer/Utils/SILInliner.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ namespace swift {
7272
/// Utility class for rewiring control-flow of inlined begin_apply functions.
7373
class BeginApplySite {
7474
SILLocation Loc;
75-
SILBuilder &Builder;
75+
SILBuilder *Builder;
7676
BeginApplyInst *BeginApply;
7777
bool HasYield = false;
7878

@@ -86,11 +86,11 @@ class BeginApplySite {
8686

8787
public:
8888
BeginApplySite(BeginApplyInst *BeginApply, SILLocation Loc,
89-
SILBuilder &Builder)
89+
SILBuilder *Builder)
9090
: Loc(Loc), Builder(Builder), BeginApply(BeginApply) {}
9191

9292
static Optional<BeginApplySite> get(FullApplySite AI, SILLocation Loc,
93-
SILBuilder &Builder) {
93+
SILBuilder *Builder) {
9494
auto *BeginApply = dyn_cast<BeginApplyInst>(AI);
9595
if (!BeginApply)
9696
return None;
@@ -150,18 +150,18 @@ class BeginApplySite {
150150
auto remappedYield = remapValue(calleeYields[i]);
151151
callerYields[i]->replaceAllUsesWith(remappedYield);
152152
}
153-
Builder.createBranch(Loc, returnToBB);
153+
Builder->createBranch(Loc, returnToBB);
154154

155155
// Add branches at the resumption sites to the resume/unwind block.
156156
if (EndApply) {
157-
SavedInsertionPointRAII savedIP(Builder, EndApplyBB);
157+
SavedInsertionPointRAII savedIP(*Builder, EndApplyBB);
158158
auto resumeBB = remapBlock(yield->getResumeBB());
159-
Builder.createBranch(EndApply->getLoc(), resumeBB);
159+
Builder->createBranch(EndApply->getLoc(), resumeBB);
160160
}
161161
if (AbortApply) {
162-
SavedInsertionPointRAII savedIP(Builder, AbortApplyBB);
162+
SavedInsertionPointRAII savedIP(*Builder, AbortApplyBB);
163163
auto unwindBB = remapBlock(yield->getUnwindBB());
164-
Builder.createBranch(AbortApply->getLoc(), unwindBB);
164+
Builder->createBranch(AbortApply->getLoc(), unwindBB);
165165
}
166166
return true;
167167
}
@@ -175,9 +175,9 @@ class BeginApplySite {
175175
bool isNormal = isa<ReturnInst>(terminator);
176176
auto returnBB = isNormal ? EndApplyReturnBB : AbortApplyReturnBB;
177177
if (returnBB) {
178-
Builder.createBranch(Loc, returnBB);
178+
Builder->createBranch(Loc, returnBB);
179179
} else {
180-
Builder.createUnreachable(Loc);
180+
Builder->createUnreachable(Loc);
181181
}
182182
return true;
183183
}
@@ -200,18 +200,18 @@ class BeginApplySite {
200200
if (!HasYield) {
201201
// Make sure the split resumption blocks have terminators.
202202
if (EndApplyBB) {
203-
SavedInsertionPointRAII savedIP(Builder, EndApplyBB);
204-
Builder.createUnreachable(Loc);
203+
SavedInsertionPointRAII savedIP(*Builder, EndApplyBB);
204+
Builder->createUnreachable(Loc);
205205
}
206206
if (AbortApplyBB) {
207-
SavedInsertionPointRAII savedIP(Builder, AbortApplyBB);
208-
Builder.createUnreachable(Loc);
207+
SavedInsertionPointRAII savedIP(*Builder, AbortApplyBB);
208+
Builder->createUnreachable(Loc);
209209
}
210210

211211
// Replace all the yielded values in the callee with undef.
212212
for (auto calleeYield : BeginApply->getYieldedValues()) {
213-
calleeYield->replaceAllUsesWith(SILUndef::get(calleeYield->getType(),
214-
Builder.getModule()));
213+
calleeYield->replaceAllUsesWith(
214+
SILUndef::get(calleeYield->getType(), Builder->getModule()));
215215
}
216216
}
217217

@@ -380,7 +380,7 @@ SILInlineCloner::SILInlineCloner(
380380
assert(CallSiteScope->getParentFunction() == &F);
381381

382382
// Set up the coroutine-specific inliner if applicable.
383-
BeginApply = BeginApplySite::get(apply, Loc.getValue(), getBuilder());
383+
BeginApply = BeginApplySite::get(apply, Loc.getValue(), &getBuilder());
384384
}
385385

386386
// Clone the entire callee function into the caller function at the apply site.

0 commit comments

Comments
 (0)