Skip to content

Commit 81812ea

Browse files
authored
Merge pull request #72389 from eeckstein/copy-addr-effect
SIL: fix runtime effect of copy_addr of trivial types
2 parents f24e18c + 20ca456 commit 81812ea

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/SIL/Utils/InstructionUtils.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,8 @@ RuntimeEffect swift::getRuntimeEffect(SILInstruction *inst, SILType &impactType)
746746

747747
case SILInstructionKind::CopyAddrInst: {
748748
auto *ca = cast<CopyAddrInst>(inst);
749+
if (ca->getSrc()->getType().isTrivial(ca->getFunction()))
750+
return RuntimeEffect::NoEffect;
749751
impactType = ca->getSrc()->getType();
750752
if (!ca->isInitializationOfDest())
751753
return RuntimeEffect::MetaData | RuntimeEffect::Releasing;

test/SILOptimizer/performance-annotations.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,3 +492,16 @@ func matchCEnum(_ variant: c_closed_enum_t) -> Int {
492492
}
493493
}
494494

495+
public struct GenericStruct<T> {
496+
private var x = 0
497+
private var y: T?
498+
@inline(never)
499+
init() {}
500+
}
501+
502+
@_noLocks
503+
func testLargeTuple() {
504+
typealias SixInt8s = (Int8, Int8, Int8, Int8, Int8, Int8)
505+
_ = GenericStruct<SixInt8s>()
506+
}
507+

0 commit comments

Comments
 (0)