Skip to content

Commit b3b9d28

Browse files
committed
OpaqueValues: support SILGen for copy expr
This doesn't cover AddressLowering of `explicit_copy_value`.
1 parent 4a943d4 commit b3b9d28

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/SILGen/SILGenExpr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7323,7 +7323,7 @@ RValue RValueEmitter::visitCopyExpr(CopyExpr *E, SGFContext C) {
73237323
return RValue(SGF, {optTemp->getManagedAddress()}, subType.getASTType());
73247324
}
73257325

7326-
if (subType.isLoadable(SGF.F)) {
7326+
if (subType.isLoadable(SGF.F) || !SGF.silConv.useLoweredAddresses()) {
73277327
ManagedValue mv =
73287328
SGF.emitRValue(subExpr, SGFContext::AllowImmediatePlusZero)
73297329
.getAsSingleValue(SGF, subExpr);

test/SILGen/opaque_values_silgen.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,3 +885,14 @@ struct Twople<T> {
885885
func throwTypedValue(_ e: Err) throws(Err) { throw e }
886886

887887
struct Err : Error {}
888+
889+
// CHECK-LABEL: sil{{.*}} [ossa] @copy_expr_generic : {{.*}} {
890+
// CHECK: bb0([[E:%[^,]+]] : @guaranteed $T
891+
// CHECK: [[E_COPY:%[^,]+]] = explicit_copy_value [[E]]
892+
// CHECK: apply {{.*}}<T>([[E_COPY]])
893+
// CHECK-LABEL: } // end sil function 'copy_expr_generic'
894+
@_silgen_name("copy_expr_generic")
895+
func copy_expr_generic<T>(_ t: T) {
896+
eat_generic(copy t)
897+
}
898+
func eat_generic<T>(_ t: consuming T) {}

0 commit comments

Comments
 (0)