1- // REQUIRES: rdar73931872
21// RUN: %target-sil-opt -enable-objc-interop -enforce-exclusivity=none -enable-sil-verify-all %s -sil-combine | %FileCheck %s
32
43// Declare this SIL to be canonical because some tests break raw SIL
@@ -4665,71 +4664,78 @@ bb1(%2a : @guaranteed $Builtin.NativeObject):
46654664 return %3 : $Builtin.NativeObject
46664665}
46674666
4668- // CHECK-LABEL: sil [ossa] @cowbuffer_reading_immutable_1 : $@convention(method) <Element> (@guaranteed _ContiguousArrayBuffer<Element>) -> Int {
4667+ // CHECK-LABEL: sil [ossa] @cowbuffer_reading_immutable_1 : $@convention(method) <Element> (@guaranteed _ContiguousArrayBuffer<Element>) -> MyInt {
4668+ // CHECK-NOT: builtin "COWBufferForReading"
46694669// CHECK: ref_element_addr [immutable]
4670+ // CHECK-NOT: builtin "COWBufferForReading"
46704671// CHECK: } // end sil function 'cowbuffer_reading_immutable_1'
4671- sil [ossa] @cowbuffer_reading_immutable_1 : $@convention(method) <Element> (@guaranteed _ContiguousArrayBuffer<Element>) -> Int {
4672+ sil [ossa] @cowbuffer_reading_immutable_1 : $@convention(method) <Element> (@guaranteed _ContiguousArrayBuffer<Element>) -> MyInt {
46724673bb0(%0 : @guaranteed $_ContiguousArrayBuffer<Element>):
46734674 %3 = struct_extract %0 : $_ContiguousArrayBuffer<Element>, #_ContiguousArrayBuffer._storage
46744675 %4 = copy_value %3 : $__ContiguousArrayStorageBase
46754676 %5 = builtin "COWBufferForReading"<__ContiguousArrayStorageBase>(%4 : $__ContiguousArrayStorageBase) : $__ContiguousArrayStorageBase
46764677 %6 = begin_borrow %5 : $__ContiguousArrayStorageBase
46774678 %7 = ref_element_addr %6 : $__ContiguousArrayStorageBase, #__ContiguousArrayStorageBase.countAndCapacity
4678- %8 = load [trivial] %7 : $*_ArrayBody
4679- debug_value %8 : $_ArrayBody, let, name "self", argno 1
4680- %10 = struct_extract %8 : $_ArrayBody, #_ArrayBody._storage
4681- %11 = struct_extract %10 : $_SwiftArrayBodyStorage, #_SwiftArrayBodyStorage.count
4682- %12 = struct_extract %11 : $Int, #Int._value
4683- %13 = builtin "assumeNonNegative_Int64"(%12 : $Builtin.Int64) : $Builtin.Int64
4684- %14 = struct $Int (%13 : $Builtin.Int64)
4679+ // I am doing this to avoid exposing 32 vs 64 bit. It is evil and just for
4680+ // testing.
4681+ %7a = unchecked_addr_cast %7 : $*_ArrayBody to $*Builtin.Int32
4682+ %8 = load [trivial] %7a : $*Builtin.Int32
4683+ debug_value %8 : $Builtin.Int32, let, name "self", argno 1
4684+ %14 = struct $MyInt (%8 : $Builtin.Int32)
46854685 end_borrow %6 : $__ContiguousArrayStorageBase
46864686 destroy_value %5 : $__ContiguousArrayStorageBase
4687- return %14 : $Int
4687+ return %14 : $MyInt
46884688}
46894689
4690- // CHECK-LABEL: sil [ossa] @cowbuffer_reading_no_crash_derived_borrow : $@convention(method) <Element> (@guaranteed _ContiguousArrayBuffer<Element>) -> Int {
4690+ // CHECK-LABEL: sil [ossa] @cowbuffer_reading_no_crash_derived_borrow : $@convention(method) <Element> (@guaranteed _ContiguousArrayBuffer<Element>) -> MyInt {
4691+ // CHECK-NOT: builtin "COWBufferForReading"
46914692// CHECK: ref_element_addr [immutable]
4693+ // CHECK-NOT: builtin "COWBufferForReading"
46924694// CHECK: ref_tail_addr [immutable]
4695+ // CHECK-NOT: builtin "COWBufferForReading"
46934696// CHECK: } // end sil function 'cowbuffer_reading_no_crash_derived_borrow'
4694- sil [ossa] @cowbuffer_reading_no_crash_derived_borrow : $@convention(method) <Element> (@guaranteed _ContiguousArrayBuffer<Element>) -> Int {
4697+ sil [ossa] @cowbuffer_reading_no_crash_derived_borrow : $@convention(method) <Element> (@guaranteed _ContiguousArrayBuffer<Element>) -> MyInt {
46954698bb0(%0 : @guaranteed $_ContiguousArrayBuffer<Element>):
46964699 %3 = struct_extract %0 : $_ContiguousArrayBuffer<Element>, #_ContiguousArrayBuffer._storage
46974700 %4 = copy_value %3 : $__ContiguousArrayStorageBase
46984701 %5 = builtin "COWBufferForReading"<__ContiguousArrayStorageBase>(%4 : $__ContiguousArrayStorageBase) : $__ContiguousArrayStorageBase
46994702 %6 = begin_borrow %5 : $__ContiguousArrayStorageBase
47004703 %6b = begin_borrow %6 : $__ContiguousArrayStorageBase
47014704 %7 = ref_element_addr %6b : $__ContiguousArrayStorageBase, #__ContiguousArrayStorageBase.countAndCapacity
4702- %8 = load [trivial] %7 : $*_ArrayBody
4703- debug_value %8 : $_ArrayBody, let, name "self", argno 1
4704- %10 = struct_extract %8 : $_ArrayBody, #_ArrayBody._storage
4705- %11 = struct_extract %10 : $_SwiftArrayBodyStorage, #_SwiftArrayBodyStorage.count
4706- %12 = struct_extract %11 : $Int, #Int._value
4705+ // This is evil! I am doing it just for this test to avoid platform 32 vs 64
4706+ // integer size issues.
4707+ %7a = unchecked_addr_cast %7 : $* _ArrayBody to $*Builtin.Int32
4708+ %8 = load [trivial] %7a : $*Builtin.Int32
4709+ debug_value %8 : $Builtin.Int32, let, name "self", argno 1
47074710 end_borrow %6b : $__ContiguousArrayStorageBase
47084711 %6c = begin_borrow %6 : $__ContiguousArrayStorageBase
47094712 %7b = ref_tail_addr %6c : $__ContiguousArrayStorageBase, $Element
4710- // This is evil! I am doing it just for this test!
4711- %7c = unchecked_addr_cast %7b : $*Element to $*Builtin.Int64
4712- %12b = load [trivial] %7c : $*Builtin.Int64
4713+ // This is evil! I am doing it just for this test to avoid platform 32 vs 64
4714+ // integer size issues.
4715+ %7c = unchecked_addr_cast %7b : $*Element to $*Builtin.Int32
4716+ %12b = load [trivial] %7c : $*Builtin.Int32
47134717 end_borrow %6c : $__ContiguousArrayStorageBase
47144718 end_borrow %6 : $__ContiguousArrayStorageBase
47154719 destroy_value %5 : $__ContiguousArrayStorageBase
4716- %12c = builtin "and_Int64"(%12 : $Builtin.Int64, %12b : $Builtin.Int64) : $Builtin.Int64
4717- %13 = builtin "assumeNonNegative_Int64"(%12c : $Builtin.Int64) : $Builtin.Int64
4718- %14 = struct $Int (%13 : $Builtin.Int64)
4719- return %14 : $Int
4720+ %12c = builtin "and_Int32"(%8 : $Builtin.Int32, %12b : $Builtin.Int32) : $Builtin.Int32
4721+ %14 = struct $MyInt (%12c : $Builtin.Int32)
4722+ return %14 : $MyInt
47204723}
47214724
4722- // CHECK-LABEL: sil [ossa] @cowbuffer_reading_no_lookthrough_reborrow : $@convention(method) <Element> (@guaranteed _ContiguousArrayBuffer<Element>) -> Int {
4725+ // CHECK-LABEL: sil [ossa] @cowbuffer_reading_no_lookthrough_reborrow : $@convention(method) <Element> (@guaranteed _ContiguousArrayBuffer<Element>) -> MyInt {
47234726// CHECK-NOT: ref_element_addr [immutable]
47244727// CHECK-NOT: ref_tail_addr [immutable]
4728+ // CHECK-NOT: builtin "COWBufferForReading"
47254729// CHECK: ref_element_addr %
47264730// CHECK-NOT: ref_element_addr [immutable]
47274731// CHECK-NOT: ref_tail_addr [immutable]
4732+ // CHECK-NOT: builtin "COWBufferForReading"
47284733// CHECK: ref_tail_addr %
47294734// CHECK-NOT: ref_element_addr [immutable]
47304735// CHECK-NOT: ref_tail_addr [immutable]
4736+ // CHECK-NOT: builtin "COWBufferForReading"
47314737// CHECK: } // end sil function 'cowbuffer_reading_no_lookthrough_reborrow'
4732- sil [ossa] @cowbuffer_reading_no_lookthrough_reborrow : $@convention(method) <Element> (@guaranteed _ContiguousArrayBuffer<Element>) -> Int {
4738+ sil [ossa] @cowbuffer_reading_no_lookthrough_reborrow : $@convention(method) <Element> (@guaranteed _ContiguousArrayBuffer<Element>) -> MyInt {
47334739bb0(%0 : @guaranteed $_ContiguousArrayBuffer<Element>):
47344740 %3 = struct_extract %0 : $_ContiguousArrayBuffer<Element>, #_ContiguousArrayBuffer._storage
47354741 %4 = copy_value %3 : $__ContiguousArrayStorageBase
@@ -4740,25 +4746,26 @@ bb0(%0 : @guaranteed $_ContiguousArrayBuffer<Element>):
47404746
47414747bb1(%6b : @guaranteed $__ContiguousArrayStorageBase):
47424748 %7 = ref_element_addr %6b : $__ContiguousArrayStorageBase, #__ContiguousArrayStorageBase.countAndCapacity
4743- %8 = load [trivial] %7 : $*_ArrayBody
4744- debug_value %8 : $_ArrayBody, let, name "self", argno 1
4745- %10 = struct_extract %8 : $_ArrayBody, #_ArrayBody._storage
4746- %11 = struct_extract %10 : $_SwiftArrayBodyStorage, #_SwiftArrayBodyStorage.count
4747- %12 = struct_extract %11 : $Int, #Int._value
4749+ // This is evil! I am doing it just for this test to avoid platform 32 vs 32
4750+ // integer size issues.
4751+ %7a = unchecked_addr_cast %7 : $* _ArrayBody to $*Builtin.Int32
4752+ %8 = load [trivial] %7a : $*Builtin.Int32
4753+ debug_value %8 : $Builtin.Int32, let, name "self", argno 1
47484754 end_borrow %6b : $__ContiguousArrayStorageBase
47494755 %6cb = begin_borrow %6 : $__ContiguousArrayStorageBase
47504756 br bb2(%6cb : $__ContiguousArrayStorageBase)
47514757
47524758bb2(%6c : @guaranteed $__ContiguousArrayStorageBase):
47534759 %7b = ref_tail_addr %6c : $__ContiguousArrayStorageBase, $Element
4754- // This is evil! I am doing it just for this test!
4755- %7c = unchecked_addr_cast %7b : $*Element to $*Builtin.Int64
4756- %12b = load [trivial] %7c : $*Builtin.Int64
4760+ // This is evil! I am doing it just for this test to avoid platform 32 vs 32
4761+ // integer size issues.
4762+ %7c = unchecked_addr_cast %7b : $*Element to $*Builtin.Int32
4763+ %12b = load [trivial] %7c : $*Builtin.Int32
47574764 end_borrow %6c : $__ContiguousArrayStorageBase
47584765 end_borrow %6 : $__ContiguousArrayStorageBase
47594766 destroy_value %5 : $__ContiguousArrayStorageBase
4760- %12c = builtin "and_Int64 "(%12 : $Builtin.Int64 , %12b : $Builtin.Int64 ) : $Builtin.Int64
4761- %13 = builtin "assumeNonNegative_Int64 "(%12c : $Builtin.Int64 ) : $Builtin.Int64
4762- %14 = struct $Int (%13 : $Builtin.Int64 )
4763- return %14 : $Int
4767+ %12c = builtin "and_Int32 "(%8 : $Builtin.Int32 , %12b : $Builtin.Int32 ) : $Builtin.Int32
4768+ %13 = builtin "assumeNonNegative_Int32 "(%12c : $Builtin.Int32 ) : $Builtin.Int32
4769+ %14 = struct $MyInt (%13 : $Builtin.Int32 )
4770+ return %14 : $MyInt
47644771}
0 commit comments