Skip to content

Commit 7059782

Browse files
authored
Merge pull request #19082 from rjmccall/no-dict-details
2 parents 123d27d + c834f72 commit 7059782

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

test/SILOptimizer/access_marker_verify.swift

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -445,28 +445,36 @@ func testEnumLValue(s: inout StructOfEnum) {
445445
enumLValueHelper(&s.e, &s.f)
446446
}
447447

448+
struct MyDict<K: Hashable, V> {
449+
let s = "" // make this non-trivial
450+
subscript(key: K) -> V? {
451+
get { return nil }
452+
set {}
453+
}
454+
}
455+
448456
// --- Optional access.
449-
func accessOptionalArray(_ dict : [Int : [Int]] = [:]) {
457+
func accessOptionalArray(_ dict : MyDict<Int, [Int]>) {
450458
var dict = dict
451459
dict[1]?.append(2)
452460
}
453-
// CHECK-LABEL: sil hidden @$S20access_marker_verify0A13OptionalArrayyySDySiSaySiGGF : $@convention(thin) (@guaranteed Dictionary<Int, Array<Int>>) -> () {
454-
// CHECK: bb0(%0 : @guaranteed $Dictionary<Int, Array<Int>>):
455-
// CHECK: alloc_box ${ var Dictionary<Int, Array<Int>> }, var, name "dict"
461+
// CHECK-LABEL: sil hidden @$S20access_marker_verify0A13OptionalArrayyyAA6MyDictVySiSaySiGGF : $@convention(thin) (@guaranteed MyDict<Int, Array<Int>>) -> () {
462+
// CHECK: bb0(%0 : @guaranteed $MyDict<Int, Array<Int>>):
463+
// CHECK: alloc_box ${ var MyDict<Int, Array<Int>> }, var, name "dict"
456464
// CHECK: [[PROJ:%.*]] = project_box
457465
// ----- initialize the box.
458466
// CHECK: [[INITACCESS:%.*]] = begin_access [modify] [unsafe] [[PROJ]]
459467
// CHECK: store %{{.*}} to [init] [[INITACCESS]]
460468
// CHECK: end_access [[INITACCESS]]
461-
// ----- begin formal access for Dictionary.subscript.setter
469+
// ----- begin formal access for MyDict.subscript.setter
462470
// CHECK: [[BOXACCESS:%.*]] = begin_access [modify] [unknown] [[PROJ]]
463471
// CHECK: [[TEMP:%.*]] = alloc_stack $Optional<Array<Int>>
464-
// CHECK: load_borrow [[BOXACCESS]] : $*Dictionary<Int, Array<Int>>
472+
// CHECK: load_borrow [[BOXACCESS]] : $*MyDict<Int, Array<Int>>
465473
// ----- Initialize some trivial temporaries.
466474
// CHECK: alloc_stack $Int
467475
// CHECK-NOT: begin_access
468476
// CHECK: store %{{.*}} to [trivial]
469-
// ----- Call Dictionary.subscript.getter.
477+
// ----- Call MyDict.subscript.getter.
470478
// CHECK-NOT: begin_access
471479
// CHECK: apply %{{.*}}<Int, [Int]>
472480
// ----- access the temporary array result of the getter
@@ -482,10 +490,10 @@ func accessOptionalArray(_ dict : [Int : [Int]] = [:]) {
482490
// CHECK: [[TEMP3:%.*]] = alloc_stack $Int
483491
// CHECK-NOT: begin_access
484492
// CHECK: store %{{.*}} to [trivial] [[TEMP3]] : $*Int
485-
// Call Dictionary.subscript.setter
486-
// CHECK: apply %{{.*}}<Int, [Int]>([[WRITEBACK]], [[TEMP3]], [[BOXACCESS]]) : $@convention(method) <τ_0_0, τ_0_1 where τ_0_0 : Hashable> (@in Optional<τ_0_1>, @in τ_0_0, @inout Dictionary<τ_0_0, τ_0_1>) -> ()
493+
// Call MyDict.subscript.setter
494+
// CHECK: apply %{{.*}}<Int, [Int]>([[WRITEBACK]], [[TEMP3]], [[BOXACCESS]]) : $@convention(method) <τ_0_0, τ_0_1 where τ_0_0 : Hashable> (@in Optional<τ_0_1>, @in τ_0_0, @inout MyDict<τ_0_0, τ_0_1>) -> ()
487495
// CHECK: end_access [[TEMPACCESS]] : $*Optional<Array<Int>>
488-
// CHECK: end_access [[BOXACCESS]] : $*Dictionary<Int, Array<Int>>
496+
// CHECK: end_access [[BOXACCESS]] : $*MyDict<Int, Array<Int>>
489497
// CHECK: br
490498
//
491499
// CHECK: bb2:
@@ -501,9 +509,9 @@ func accessOptionalArray(_ dict : [Int : [Int]] = [:]) {
501509
// CHECK: store [[TEMPARRAYVAL]] to [init] [[ARRAYCOPY]] : $*Optional<Array<Int>>
502510
// CHECK: alloc_stack $Int
503511
// CHECK: store %{{.*}} to [trivial]
504-
// ----- call Dictionary.subscript.setter
505-
// CHECK: apply %{{.*}}<Int, [Int]>([[ARRAYCOPY]], %{{.*}}, [[BOXACCESS]]) : $@convention(method) <τ_0_0, τ_0_1 where τ_0_0 : Hashable> (@in Optional<τ_0_1>, @in τ_0_0, @inout Dictionary<τ_0_0, τ_0_1>) -> ()
506-
// CHECK-LABEL: } // end sil function '$S20access_marker_verify0A13OptionalArrayyySDySiSaySiGGF'
512+
// ----- call MyDict.subscript.setter
513+
// CHECK: apply %{{.*}}<Int, [Int]>([[ARRAYCOPY]], %{{.*}}, [[BOXACCESS]]) : $@convention(method) <τ_0_0, τ_0_1 where τ_0_0 : Hashable> (@in Optional<τ_0_1>, @in τ_0_0, @inout MyDict<τ_0_0, τ_0_1>) -> ()
514+
// CHECK-LABEL: } // end sil function '$S20access_marker_verify0A13OptionalArrayyyAA6MyDictVySiSaySiGGF'
507515

508516
// --- Optional map.
509517
enum OptionalWithMap<Wrapped> {

0 commit comments

Comments
 (0)