Skip to content

Commit aa76a68

Browse files
committed
SIL: fix runtime effects of initializing store
An initializing store is not a copy and therefore doesn't perform ref counting operations Fixes a false performance error when using non-copyable types. swiftlang#73582
1 parent cef6a6c commit aa76a68

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

lib/SIL/Utils/InstructionUtils.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -780,9 +780,8 @@ RuntimeEffect swift::getRuntimeEffect(SILInstruction *inst, SILType &impactType)
780780
switch (cast<StoreInst>(inst)->getOwnershipQualifier()) {
781781
case StoreOwnershipQualifier::Unqualified:
782782
case StoreOwnershipQualifier::Trivial:
783-
return RuntimeEffect::NoEffect;
784783
case StoreOwnershipQualifier::Init:
785-
return RuntimeEffect::RefCounting;
784+
return RuntimeEffect::NoEffect;
786785
case StoreOwnershipQualifier::Assign:
787786
return RuntimeEffect::Releasing;
788787
}

test/SILOptimizer/performance-annotations.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,3 +505,12 @@ func testLargeTuple() {
505505
_ = GenericStruct<SixInt8s>()
506506
}
507507

508+
struct NonCopyableStruct: ~Copyable {
509+
func foo() {}
510+
}
511+
512+
@_noLocks
513+
func testNonCopyable() {
514+
let t = NonCopyableStruct()
515+
t.foo()
516+
}

0 commit comments

Comments
 (0)