@@ -505,20 +505,45 @@ bb0(%0 : $*Builtin.Word, %1 : $Builtin.RawPointer):
505505 return %7 : $(Builtin.Word, Builtin.RawPointer)
506506}
507507
508- // CHECK-LABEL: sil [ossa] @a2p_p2a_reinterpret_cast_word_raw_pointer
508+ // CHECK-LABEL: sil [ossa] @a2p_p2a_reinterpret_cast_word_raw_pointer1
509509// CHECK: bb0
510510// CHECK-NEXT: unchecked_addr_cast
511511// CHECK-NEXT: load
512512// CHECK-NEXT: return
513- // CHECK: } // end sil function 'a2p_p2a_reinterpret_cast_word_raw_pointer '
514- sil [ossa] @a2p_p2a_reinterpret_cast_word_raw_pointer : $@convention(thin) (@inout Builtin.Word, Builtin.RawPointer) -> Int32 {
513+ // CHECK: } // end sil function 'a2p_p2a_reinterpret_cast_word_raw_pointer1 '
514+ sil [ossa] @a2p_p2a_reinterpret_cast_word_raw_pointer1 : $@convention(thin) (@inout Builtin.Word, Builtin.RawPointer) -> Int32 {
515515bb0(%0 : $*Builtin.Word, %1 : $Builtin.RawPointer):
516516 %2 = address_to_pointer %0 : $*Builtin.Word to $Builtin.RawPointer
517517 %3 = pointer_to_address %2 : $Builtin.RawPointer to [strict] $*Int32
518518 %4 = load [trivial] %3 : $*Int32
519519 return %4 : $Int32
520520}
521521
522+ sil @useInt : $@convention(thin) (Int32) -> ()
523+
524+ // CHECK-LABEL: sil [ossa] @a2p_p2a_reinterpret_cast_word_raw_pointer2
525+ // CHECK: unchecked_addr_cast
526+ // CHECK: } // end sil function 'a2p_p2a_reinterpret_cast_word_raw_pointer2'
527+ sil [ossa] @a2p_p2a_reinterpret_cast_word_raw_pointer2 : $@convention(thin) (@owned ContiguousArray<UInt16>) -> () {
528+ bb0(%0 : @owned $ContiguousArray<UInt16>):
529+ %1 = begin_borrow %0 : $ContiguousArray<UInt16>
530+ %2 = struct_extract %1 : $ContiguousArray<UInt16>, #ContiguousArray._buffer
531+ %3 = struct_extract %2 : $_ContiguousArrayBuffer<UInt16>, #_ContiguousArrayBuffer._storage
532+ %4 = ref_tail_addr %3 : $__ContiguousArrayStorageBase, $UInt16
533+ %5 = address_to_pointer %4 : $*UInt16 to $Builtin.RawPointer
534+ br bb1
535+
536+ bb1:
537+ %6 = pointer_to_address %5 : $Builtin.RawPointer to [strict] $*Int32
538+ %7 = load [trivial] %6 : $*Int32
539+ %8 = function_ref @useInt : $@convention(thin) (Int32) -> ()
540+ %9 = apply %8(%7) : $@convention(thin) (Int32) -> ()
541+ end_borrow %1 : $ContiguousArray<UInt16>
542+ destroy_value %0 : $ContiguousArray<UInt16>
543+ %12 = tuple ()
544+ return %12 : $()
545+ }
546+
522547// CHECK-LABEL: sil [ossa] @sil_extract_of_string
523548//
524549// Make sure we only forward the first field of the string_literal
0 commit comments