Skip to content

Commit af54147

Browse files
authored
Merge pull request #25472 from dcci/silbuilder-inherit
[SILInliner] Inherit SILBuilderContext when creating a new one.
2 parents 8839741 + 36b917b commit af54147

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

include/swift/SIL/SILBuilder.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2232,6 +2232,9 @@ class SILBuilderWithScope : public SILBuilder {
22322232
explicit SILBuilderWithScope(SILBasicBlock::iterator I)
22332233
: SILBuilderWithScope(&*I) {}
22342234

2235+
explicit SILBuilderWithScope(SILBasicBlock::iterator I, SILBuilder &B)
2236+
: SILBuilder(&*I, &*I->getDebugScope(), B.getBuilderContext()) {}
2237+
22352238
explicit SILBuilderWithScope(SILInstruction *I,
22362239
SILInstruction *InheritScopeFrom)
22372240
: SILBuilderWithScope(I) {

lib/SILOptimizer/Utils/SILInliner.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -563,14 +563,16 @@ SILValue SILInlineCloner::borrowFunctionArgument(SILValue callArg,
563563
SILBuilderWithScope beginBuilder(AI.getInstruction(), getBuilder());
564564
auto *borrow = beginBuilder.createBeginBorrow(AI.getLoc(), callArg);
565565
if (auto *tryAI = dyn_cast<TryApplyInst>(AI)) {
566-
SILBuilderWithScope returnBuilder(tryAI->getNormalBB()->begin());
566+
SILBuilderWithScope returnBuilder(tryAI->getNormalBB()->begin(),
567+
getBuilder());
567568
returnBuilder.createEndBorrow(AI.getLoc(), borrow, callArg);
568569

569-
SILBuilderWithScope throwBuilder(tryAI->getErrorBB()->begin());
570+
SILBuilderWithScope throwBuilder(tryAI->getErrorBB()->begin(),
571+
getBuilder());
570572
throwBuilder.createEndBorrow(AI.getLoc(), borrow, callArg);
571573
} else {
572574
SILBuilderWithScope returnBuilder(
573-
std::next(AI.getInstruction()->getIterator()));
575+
std::next(AI.getInstruction()->getIterator()), getBuilder());
574576
returnBuilder.createEndBorrow(AI.getLoc(), borrow, callArg);
575577
}
576578
return borrow;

0 commit comments

Comments
 (0)