@@ -206,13 +206,21 @@ ManagedValue ManagedValue::materialize(SILGenFunction &SGF,
206
206
StoreOwnershipQualifier::Init);
207
207
208
208
// SEMANTIC SIL TODO: This should really be called a temporary LValue.
209
- return ManagedValue::forOwnedAddressRValue (temporary,
210
- SGF.enterDestroyCleanup (temporary));
211
- } else {
212
- auto object = SGF.emitManagedBeginBorrow (loc, getValue ());
213
- SGF.emitManagedStoreBorrow (loc, object.getValue (), temporary);
214
- return ManagedValue::forBorrowedAddressRValue (temporary);
209
+ return ManagedValue::forOwnedAddressRValue (
210
+ temporary, SGF.enterDestroyCleanup (temporary));
211
+ }
212
+ auto &lowering = SGF.getTypeLowering (getType ());
213
+ if (lowering.isAddressOnly ()) {
214
+ assert (!SGF.silConv .useLoweredAddresses ());
215
+ auto copy = SGF.B .createCopyValue (loc, getValue ());
216
+ SGF.B .emitStoreValueOperation (loc, copy, temporary,
217
+ StoreOwnershipQualifier::Init);
218
+ return ManagedValue::forOwnedAddressRValue (
219
+ temporary, SGF.enterDestroyCleanup (temporary));
215
220
}
221
+ auto object = SGF.emitManagedBeginBorrow (loc, getValue ());
222
+ SGF.emitManagedStoreBorrow (loc, object.getValue (), temporary);
223
+ return ManagedValue::forBorrowedAddressRValue (temporary);
216
224
}
217
225
218
226
void ManagedValue::print (raw_ostream &os) const {
0 commit comments