diff --git a/lib/SILGen/SILGenLValue.cpp b/lib/SILGen/SILGenLValue.cpp index 2c906ddb64c0c..23df4448b9f58 100644 --- a/lib/SILGen/SILGenLValue.cpp +++ b/lib/SILGen/SILGenLValue.cpp @@ -5234,7 +5234,9 @@ void SILGenFunction::emitSemanticStore(SILLocation loc, assert(!silConv.useLoweredAddresses() || (dest->getType().isAddressOnly(F) == rvalue->getType().isAddress())); if (rvalue->getType().isAddress()) { - B.createCopyAddr(loc, rvalue, dest, IsTake, isInit); + B.createCopyAddr(loc, rvalue, dest, + rvalue->getType().isTrivial(F) ? IsNotTake : IsTake, + isInit); } else { emitUnloweredStoreOfCopy(B, loc, rvalue, dest, isInit); } diff --git a/test/SILGen/trivial_address_only_switch.swift b/test/SILGen/trivial_address_only_switch.swift new file mode 100644 index 0000000000000..8a272250b809c --- /dev/null +++ b/test/SILGen/trivial_address_only_switch.swift @@ -0,0 +1,15 @@ +// RUN: %target-swift-emit-silgen -verify -disable-availability-checking %s + +public enum StreamYieldResult: Sendable { + case literal(buffer: InlineArray) + case end(buffer: InlineArray, endIndex: Int) + + public func buffer() -> InlineArray { + switch self { + case .literal(let b): + return b + case .end(let b, _): + return b + } + } +} diff --git a/test/SILGen/variadic-generic-tuples.swift b/test/SILGen/variadic-generic-tuples.swift index 6c63a4881101a..007253c2be790 100644 --- a/test/SILGen/variadic-generic-tuples.swift +++ b/test/SILGen/variadic-generic-tuples.swift @@ -102,7 +102,7 @@ public struct Container { // Finally, the actual assignment. // CHECK-NEXT: [[ACCESS:%.*]] = begin_access [modify] [unknown] %1 : // CHECK-NEXT: [[FIELD:%.*]] = struct_element_addr [[ACCESS]] : $*Container, #Container.storage -// CHECK-NEXT: copy_addr [take] [[COPY2]] to [[FIELD]] : $*(repeat Stored) +// CHECK-NEXT: copy_addr [[COPY2]] to [[FIELD]] : $*(repeat Stored) // CHECK-NEXT: end_access [[ACCESS]] // Clean up. // CHECK-NEXT: dealloc_stack [[COPY2]]