Skip to content

Commit 18fd845

Browse files
committed
Create begin_borrow in OSSA only
Fixes rdar://103512260 Creating begin_borrow in non-ossa can raise asserts or reach unreachable in some utils.
1 parent cfe49a0 commit 18fd845

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

include/swift/SIL/SILBuilder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,7 @@ class SILBuilder {
745745

746746
BeginBorrowInst *createBeginBorrow(SILLocation Loc, SILValue LV,
747747
bool isLexical = false) {
748+
assert(getFunction().hasOwnership());
748749
assert(!LV->getType().isAddress());
749750
return insert(new (getModule())
750751
BeginBorrowInst(getSILDebugLocation(Loc), LV, isLexical));

lib/SILOptimizer/Utils/SILInliner.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ class BeginApplySite {
171171
// which require an @guaranteed operand into which we'd be attempting to
172172
// substitute an @owned operand.
173173
if (calleeYields[i]->getOwnershipKind() == OwnershipKind::Owned &&
174-
!yield->getOperandRef(i).isConsuming()) {
174+
!yield->getOperandRef(i).isConsuming() &&
175+
Builder->getFunction().hasOwnership()) {
175176
auto *bbi = Builder->createBeginBorrow(Loc, remappedYield);
176177
guaranteedYields.push_back(bbi);
177178
remappedYield = bbi;

0 commit comments

Comments
 (0)