Skip to content

Commit 2398181

Browse files
committed
Fix SILGen for yields that are @guaranteed but of trivial type when opaque values are enabled
1 parent d829614 commit 2398181

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/SILGen/SILGenApply.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3962,15 +3962,20 @@ SILGenFunction::emitBeginApply(SILLocation loc, ManagedValue fn,
39623962
// Manage all the yielded values.
39633963
auto yieldInfos = substFnType->getYields();
39643964
assert(yieldValues.size() == yieldInfos.size());
3965+
bool useLoweredAddresses = silConv.useLoweredAddresses();
39653966
for (auto i : indices(yieldValues)) {
39663967
auto value = yieldValues[i];
39673968
auto info = yieldInfos[i];
39683969
if (info.isIndirectInOut()) {
39693970
yields.push_back(ManagedValue::forLValue(value));
39703971
} else if (info.isConsumed()) {
3971-
yields.push_back(emitManagedRValueWithCleanup(value));
3972+
!useLoweredAddresses && value->getType().isTrivial(getFunction())
3973+
? yields.push_back(ManagedValue::forTrivialRValue(value))
3974+
: yields.push_back(emitManagedRValueWithCleanup(value));
39723975
} else if (info.isGuaranteed()) {
3973-
yields.push_back(ManagedValue::forBorrowedRValue(value));
3976+
!useLoweredAddresses && value->getType().isTrivial(getFunction())
3977+
? yields.push_back(ManagedValue::forTrivialRValue(value))
3978+
: yields.push_back(ManagedValue::forBorrowedRValue(value));
39743979
} else {
39753980
yields.push_back(ManagedValue::forTrivialRValue(value));
39763981
}

0 commit comments

Comments
 (0)