File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
SwiftCompilerSources/Sources/Optimizer/InstructionSimplification Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,11 @@ extension KeyPathInst : OnoneSimplifyable {
1919 let builder = Builder ( after: self , context)
2020 for operand in self . operands {
2121 if !operand. value. type. isTrivial ( in: parentFunction) {
22- builder. createDestroyValue ( operand: operand. value)
22+ if operand. value. type. isAddress {
23+ builder. createDestroyAddr ( address: operand. value)
24+ } else {
25+ builder. createDestroyValue ( operand: operand. value)
26+ }
2327 }
2428 }
2529 }
Original file line number Diff line number Diff line change 1+ // RUN: %target-swift-frontend -primary-file %s -enable-library-evolution -emit-sil | %FileCheck %s
2+
3+ public enum E : Hashable {
4+ case e
5+ }
6+
7+ public struct S {
8+ public var dict : [ E : Int ] = [ : ]
9+ }
10+
11+ // Check that the keypath simplification does not crash when inserting a compensating destroy.
12+
13+ // CHECK-LABEL: sil @$s26simplify_keypath_resilient6testityyF :
14+ // CHECK-NOT: keypath
15+ // CHECK: } // end sil function '$s26simplify_keypath_resilient6testityyF'
16+ @inlinable
17+ public func testit( ) {
18+ let _ = \S . dict [ . e]
19+ }
20+
21+
You can’t perform that action at this time.
0 commit comments