@@ -982,7 +982,7 @@ func s460______________foo<Element>(p: UnsafePointer<Element>) -> UnsafeBufferPo
982
982
return UnsafeBufferPointer ( start: p, count: 1 )
983
983
}
984
984
985
- // Test emitNativeToCBridgedNonoptionalValue
985
+ // Test emitNativeToCBridgedNonoptionalValue.
986
986
// ---
987
987
// CHECK-objc-LABEL: sil hidden @_T020opaque_values_silgen21s470________nativeToCyXlyp7fromAny_tF : $@convention(thin) (@in Any) -> @owned AnyObject {
988
988
// CHECK-objc bb0(%0 : $Any):
@@ -1002,7 +1002,7 @@ func s470________nativeToC(fromAny any: Any) -> AnyObject {
1002
1002
}
1003
1003
#endif
1004
1004
1005
- // Test emitOpenExistential
1005
+ // Test emitOpenExistential.
1006
1006
// ---
1007
1007
// CHECK-LABEL: sil hidden @_T020opaque_values_silgen21s480_________getErroryps0F0_p04someF0_tF : $@convention(thin) (@owned Error) -> @out Any {
1008
1008
// CHECK: bb0(%0 : $Error):
@@ -1017,6 +1017,39 @@ func s480_________getError(someError: Error) -> Any {
1017
1017
return someError
1018
1018
}
1019
1019
1020
+ // Test SILBuilder.createLoadBorrow.
1021
+ // ---
1022
+ // CHECK-LABEL: sil private @_T020opaque_values_silgen21s490_______loadBorrowyyF3FooL_V3foo7ElementQzSg5IndexQz3pos_tF : $@convention(method) <Elements where Elements : Collection> (@in Elements.Index, @inout Foo<Elements>) -> @out Optional<Elements.Element> {
1023
+ // CHECK: bb0(%0 : $Elements.Index, %1 : $*Foo<Elements>):
1024
+ // CHECK: [[READ:%.*]] = begin_access [read] [unknown] %1 : $*Foo<Elements>
1025
+ // CHECK: [[LOAD:%.*]] = load_borrow [[READ]] : $*Foo<Elements>
1026
+ // CHECK: end_access [[READ]] : $*Foo<Elements>
1027
+ // CHECK: [[EXTRACT:%.*]] = struct_extract [[LOAD]] : $Foo<Elements>, #<abstract function>Foo._elements
1028
+ // CHECK: [[COPYELT:%.*]] = copy_value [[EXTRACT]] : $Elements
1029
+ // CHECK: [[BORROW:%.*]] = begin_borrow %0 : $Elements.Index
1030
+ // CHECK: [[COPYIDX:%.*]] = copy_value [[BORROW]] : $Elements.Index
1031
+ // CHECK: [[WT:%.*]] = witness_method $Elements, #Collection.subscript!getter.1 : <Self where Self : Collection> (Self) -> (Self.Index) -> Self.Element : $@convention(witness_method) <τ_0_0 where τ_0_0 : Collection> (@in τ_0_0.Index, @in_guaranteed τ_0_0) -> @out τ_0_0.Element
1032
+ // CHECK: %{{.*}} = apply [[WT]]<Elements>([[COPYIDX]], [[COPYELT]]) : $@convention(witness_method) <τ_0_0 where τ_0_0 : Collection> (@in τ_0_0.Index, @in_guaranteed τ_0_0) -> @out τ_0_0.Element
1033
+ // CHECK: destroy_value [[COPYELT]] : $Elements
1034
+ // CHECK: [[ENUM:%.*]] = enum $Optional<Elements.Element>, #Optional.some!enumelt.1, %12 : $Elements.Element
1035
+ // CHECK: end_borrow [[BORROW]] from %0 : $Elements.Index, $Elements.Index
1036
+ // CHECK: end_borrow [[LOAD]] from [[READ]] : $Foo<Elements>, $*Foo<Elements>
1037
+ // CHECK: destroy_value %0 : $Elements.Index
1038
+ // CHECK: return %14 : $Optional<Elements.Element>
1039
+ // CHECK-LABEL: } // end sil function '_T020opaque_values_silgen21s490_______loadBorrowyyF3FooL_V3foo7ElementQzSg5IndexQz3pos_tF'
1040
+
1041
+ func s490_______loadBorrow( ) {
1042
+ struct Foo < Elements : Collection > {
1043
+ internal let _elements : Elements
1044
+
1045
+ public mutating func foo( pos: Elements . Index ) -> Elements . Element ? {
1046
+ return _elements [ pos]
1047
+ }
1048
+ }
1049
+ var foo = Foo ( _elements: [ ] )
1050
+ _ = foo. foo ( pos: 1 )
1051
+ }
1052
+
1020
1053
// Tests conditional value casts and correspondingly generated reabstraction thunk, with <T> types
1021
1054
// ---
1022
1055
// CHECK-LABEL: sil hidden @_T020opaque_values_silgen21s999_____condTFromAnyyyp_xtlF : $@convention(thin) <T> (@in Any, @in T) -> () {
0 commit comments