Skip to content

Commit 1bd2a38

Browse files
authored
Merge pull request #78886 from eeckstein/fix-devirtualize-begin-apply
Devirtualizer: fix de-virtualization of begin_apply
2 parents d5a6ff2 + 9861217 commit 1bd2a38

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/SILOptimizer/Utils/Devirtualize.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -633,11 +633,13 @@ replaceBeginApplyInst(SILBuilder &builder, SILPassManager *pm, SILLocation loc,
633633
// Insert any end_borrow if the yielded value before the token's uses.
634634
SmallVector<SILInstruction *, 4> users(
635635
makeUserIteratorRange(oldYield->getUses()));
636-
auto yieldCastRes = castValueToABICompatibleType(
637-
&builder, pm, loc, newYield, newYield->getType(), oldYield->getType(),
638-
users);
639-
oldYield->replaceAllUsesWith(yieldCastRes.first);
640-
changedCFG |= yieldCastRes.second;
636+
if (!users.empty()) {
637+
auto yieldCastRes = castValueToABICompatibleType(
638+
&builder, pm, loc, newYield, newYield->getType(), oldYield->getType(),
639+
users);
640+
oldYield->replaceAllUsesWith(yieldCastRes.first);
641+
changedCFG |= yieldCastRes.second;
642+
}
641643
}
642644

643645
if (newArgBorrows.empty())

0 commit comments

Comments
 (0)