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 : OnoneSimplifiable {
19
19
let builder = Builder ( after: self , context)
20
20
for operand in self . operands {
21
21
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
+ }
23
27
}
24
28
}
25
29
}
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