@@ -511,7 +511,7 @@ func assumeNonNegative(_ x: Builtin.Word) -> Builtin.Word {
511
511
// CHECK: bb0([[ARG:%.*]] : $O):
512
512
// CHECK: [[BORROWED_ARG:%.*]] = begin_borrow [[ARG]]
513
513
// CHECK: [[ARG_COPY:%.*]] = copy_value [[BORROWED_ARG]]
514
- // CHECK: autorelease_value [[ARG_COPY]]
514
+ // CHECK: unmanaged_autorelease_value [[ARG_COPY]]
515
515
// CHECK: destroy_value [[ARG_COPY]]
516
516
// CHECK: end_borrow [[BORROWED_ARG]] from [[ARG]]
517
517
// CHECK: destroy_value [[ARG]]
@@ -866,3 +866,56 @@ func unsafeGuaranteedEnd(_ t: Builtin.Int8) {
866
866
func bindMemory< T> ( ptr: Builtin . RawPointer , idx: Builtin . Word , _: T . Type ) {
867
867
Builtin . bindMemory ( ptr, idx, T . self)
868
868
}
869
+
870
+ //===----------------------------------------------------------------------===//
871
+ // RC Operations
872
+ //===----------------------------------------------------------------------===//
873
+
874
+ // SILGen test:
875
+ //
876
+ // CHECK-LABEL: sil hidden @_T08builtins6retain{{[_0-9a-zA-Z]*}}F : $@convention(thin) (@owned Builtin.NativeObject) -> () {
877
+ // CHECK: bb0([[P:%.*]] : $Builtin.NativeObject):
878
+ // CHECK: [[BORROWED_P:%.*]] = begin_borrow [[P]]
879
+ // CHECK: [[COPIED_P:%.*]] = copy_value [[BORROWED_P]]
880
+ // CHECK: unmanaged_retain_value [[COPIED_P]]
881
+ // CHECK: destroy_value [[COPIED_P]]
882
+ // CHECK: end_borrow [[BORROWED_P]] from [[P]]
883
+ // CHECK: destroy_value [[P]]
884
+ // CHECK: } // end sil function '_T08builtins6retain{{[_0-9a-zA-Z]*}}F'
885
+
886
+ // SIL Test. This makes sure that we properly clean up in -Onone SIL.
887
+ // CANONICAL-LABEL: sil hidden @_T08builtins6retain{{[_0-9a-zA-Z]*}}F : $@convention(thin) (@owned Builtin.NativeObject) -> () {
888
+ // CANONICAL: bb0([[P:%.*]] : $Builtin.NativeObject):
889
+ // CANONICAL-NOT: retain
890
+ // CANONICAL-NOT: release
891
+ // CANONICAL: } // end sil function '_T08builtins6retain{{[_0-9a-zA-Z]*}}F'
892
+ func retain( ptr: Builtin . NativeObject ) {
893
+ Builtin . retain ( ptr)
894
+ }
895
+
896
+ // SILGen test:
897
+ //
898
+ // CHECK-LABEL: sil hidden @_T08builtins7release{{[_0-9a-zA-Z]*}}F : $@convention(thin) (@owned Builtin.NativeObject) -> () {
899
+ // CHECK: bb0([[P:%.*]] : $Builtin.NativeObject):
900
+ // CHECK: [[BORROWED_P:%.*]] = begin_borrow [[P]]
901
+ // CHECK: [[COPIED_P:%.*]] = copy_value [[BORROWED_P]]
902
+ // CHECK: unmanaged_release_value [[COPIED_P]]
903
+ // CHECK: destroy_value [[COPIED_P]]
904
+ // CHECK: end_borrow [[BORROWED_P]] from [[P]]
905
+ // CHECK: destroy_value [[P]]
906
+ // CHECK: } // end sil function '_T08builtins7release{{[_0-9a-zA-Z]*}}F'
907
+
908
+ // SIL Test. Make sure even in -Onone code, we clean this up properly:
909
+ // CANONICAL-LABEL: sil hidden @_T08builtins7release{{[_0-9a-zA-Z]*}}F : $@convention(thin) (@owned Builtin.NativeObject) -> () {
910
+ // CANONICAL: bb0([[P:%.*]] : $Builtin.NativeObject):
911
+ // CANONICAL-NEXT: debug_value
912
+ // CANONICAL-NEXT: tuple
913
+ // CANONICAL-NEXT: strong_release [[P]]
914
+ // CANONICAL-NEXT: strong_release [[P]]
915
+ // CANONICAL-NEXT: tuple
916
+ // CANONICAL-NEXT: return
917
+ // CANONICAL: } // end sil function '_T08builtins7release{{[_0-9a-zA-Z]*}}F'
918
+
919
+ func release( ptr: Builtin . NativeObject ) {
920
+ Builtin . release ( ptr)
921
+ }
0 commit comments