Skip to content

Commit 4cf6f79

Browse files
authored
Merge pull request #62714 from meg-gupta/fixassert
Create begin_borrow in OSSA only
2 parents 5b2ce0d + 18fd845 commit 4cf6f79

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)