mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
386 lines
21 KiB
Plaintext
386 lines
21 KiB
Plaintext
// RUN: %target-sil-opt -assume-parsing-unqualified-ownership-sil -array-element-propagation %s | %FileCheck %s
|
|
sil_stage canonical
|
|
|
|
import Builtin
|
|
import Swift
|
|
|
|
struct MyInt {
|
|
@sil_stored var _value: Builtin.Int64
|
|
}
|
|
|
|
struct MyBool {}
|
|
struct _MyDependenceToken {}
|
|
|
|
struct _MyBridgeStorage {
|
|
@sil_stored var rawValue : Builtin.BridgeObject
|
|
}
|
|
|
|
struct _MyArrayBuffer<T> {
|
|
@sil_stored var _storage : _MyBridgeStorage
|
|
}
|
|
|
|
|
|
struct MyArray<T> {
|
|
@sil_stored var _buffer : _MyArrayBuffer<T>
|
|
}
|
|
|
|
sil @swift_bufferAllocate : $@convention(thin)() -> @owned AnyObject
|
|
sil [_semantics "array.uninitialized"] @adoptStorage : $@convention(thin) (@owned AnyObject, MyInt, @thin MyArray<MyInt>.Type) -> @owned (MyArray<MyInt>, UnsafeMutablePointer<MyInt>)
|
|
sil [_semantics "array.props.isNativeTypeChecked"] @hoistableIsNativeTypeChecked : $@convention(method) (@guaranteed MyArray<MyInt>) -> MyBool
|
|
sil [_semantics "array.check_subscript"] @checkSubscript : $@convention(method) (MyInt, MyBool, @guaranteed MyArray<MyInt>) -> _MyDependenceToken
|
|
sil [_semantics "array.get_element"] @getElement : $@convention(method) (MyInt, MyBool, _MyDependenceToken, @guaranteed MyArray<MyInt>) -> @out MyInt
|
|
sil [_semantics "array.get_element"] @getElement2 : $@convention(method) (MyInt, MyBool, _MyDependenceToken, @guaranteed MyArray<MyInt>) -> MyInt
|
|
sil @unknown_array_use : $@convention(method) (@guaranteed MyArray<MyInt>) -> MyBool
|
|
sil [_semantics "array.uninitialized"] @arrayAdoptStorage : $@convention(thin) (@owned AnyObject, MyInt, @thin Array<MyInt>.Type) -> @owned (Array<MyInt>, UnsafeMutablePointer<MyInt>)
|
|
sil @arrayInit : $@convention(method) (@thin Array<MyInt>.Type) -> @owned Array<MyInt>
|
|
sil [_semantics "array.append_contentsOf"] @arrayAppendContentsOf : $@convention(method) (@owned Array<MyInt>, @inout Array<MyInt>) -> ()
|
|
|
|
// CHECK-LABEL: sil @propagate01
|
|
// CHECK: struct $MyInt
|
|
// CHECK: [[V0:%.*]] = integer_literal $Builtin.Int64, 0
|
|
// CHECK: [[I0:%.*]] = struct $MyInt ([[V0]] : $Builtin.Int64)
|
|
// CHECK: [[V1:%.*]] = integer_literal $Builtin.Int64, 1
|
|
// CHECK: [[I1:%.*]] = struct $MyInt ([[V1]] : $Builtin.Int64)
|
|
// CHECK: [[V2:%.*]] = integer_literal $Builtin.Int64, 2
|
|
// CHECK: [[I2:%.*]] = struct $MyInt ([[V2]] : $Builtin.Int64)
|
|
// CHECK: [[S0:%.*]] = alloc_stack $MyInt
|
|
// CHECK: [[HFUN:%.*]] = function_ref @hoistableIsNativeTypeChecked
|
|
// CHECK-NOT: apply [[HFUN]]
|
|
// CHECK: [[CFUN:%.*]] = function_ref @checkSubscript
|
|
// CHECK-NOT: apply [[CFUN]]
|
|
// CHECK: [[GFUN:%.*]] = function_ref @getElement
|
|
// CHECK-NOT: apply [[GFUN]]
|
|
// CHECK-NOT: apply [[HFUN]]
|
|
// CHECK-NOT: apply [[CFUN]]
|
|
// CHECK-NOT: apply [[GFUN]]
|
|
// CHECK: store [[I0]] to [[S0]]
|
|
// CHECK: [[S1:%.*]] = alloc_stack $MyInt
|
|
// CHECK: store [[I1]] to [[S1]]
|
|
// CHECK: [[S2:%.*]] = alloc_stack $MyInt
|
|
// CHECK: store [[I2]] to [[S2]]
|
|
// CHECK: return
|
|
|
|
sil @propagate01 : $@convention(thin) () -> () {
|
|
%0 = function_ref @swift_bufferAllocate : $@convention(thin) () -> @owned AnyObject
|
|
%1 = integer_literal $Builtin.Int64, 3
|
|
%2 = struct $MyInt (%1 : $Builtin.Int64)
|
|
%3 = apply %0() : $@convention(thin) () -> @owned AnyObject
|
|
%4 = metatype $@thin MyArray<MyInt>.Type
|
|
%5 = function_ref @adoptStorage : $@convention(thin) (@owned AnyObject, MyInt, @thin MyArray<MyInt>.Type) -> @owned (MyArray<MyInt>, UnsafeMutablePointer<MyInt>)
|
|
%6 = apply %5(%3, %2, %4) : $@convention(thin) (@owned AnyObject, MyInt, @thin MyArray<MyInt>.Type) -> @owned (MyArray<MyInt>, UnsafeMutablePointer<MyInt>)
|
|
%7 = tuple_extract %6 : $(MyArray<MyInt>, UnsafeMutablePointer<MyInt>), 0
|
|
%8 = tuple_extract %6 : $(MyArray<MyInt>, UnsafeMutablePointer<MyInt>), 1
|
|
debug_value %7 : $MyArray<MyInt>
|
|
debug_value %8 : $UnsafeMutablePointer<MyInt>
|
|
%9 = struct_extract %8 : $UnsafeMutablePointer<MyInt>, #UnsafeMutablePointer._rawValue
|
|
%10 = pointer_to_address %9 : $Builtin.RawPointer to [strict] $*MyInt
|
|
%11 = integer_literal $Builtin.Int64, 0
|
|
%12 = struct $MyInt (%11 : $Builtin.Int64)
|
|
store %12 to %10 : $*MyInt
|
|
%13 = integer_literal $Builtin.Word, 1
|
|
%14 = index_addr %10 : $*MyInt, %13 : $Builtin.Word
|
|
%15 = integer_literal $Builtin.Int64, 1
|
|
%16 = struct $MyInt (%15 : $Builtin.Int64)
|
|
store %16 to %14 : $*MyInt
|
|
%17 = integer_literal $Builtin.Word, 2
|
|
%18 = index_addr %10 : $*MyInt, %17 : $Builtin.Word
|
|
%19 = integer_literal $Builtin.Int64, 2
|
|
%20 = struct $MyInt (%19 : $Builtin.Int64)
|
|
store %20 to %18 : $*MyInt
|
|
%23 = struct_extract %7 : $MyArray<MyInt>, #MyArray._buffer
|
|
%24 = struct_extract %23 : $_MyArrayBuffer<MyInt>, #_MyArrayBuffer._storage
|
|
%25 = struct_extract %24 : $_MyBridgeStorage, #_MyBridgeStorage.rawValue
|
|
%26 = alloc_stack $MyInt
|
|
debug_value %7 : $MyArray<MyInt>
|
|
%27 = function_ref @hoistableIsNativeTypeChecked : $@convention(method) (@guaranteed MyArray<MyInt>) -> MyBool
|
|
%28 = apply %27(%7) : $@convention(method) (@guaranteed MyArray<MyInt>) -> MyBool
|
|
debug_value %28 : $MyBool // id: %104
|
|
%29 = function_ref @checkSubscript : $@convention(method) (MyInt, MyBool, @guaranteed MyArray<MyInt>) -> _MyDependenceToken
|
|
%30 = apply %29(%12, %28, %7) : $@convention(method) (MyInt, MyBool, @guaranteed MyArray<MyInt>) -> _MyDependenceToken
|
|
debug_value %30 : $_MyDependenceToken
|
|
%31 = function_ref @getElement : $@convention(method) (MyInt, MyBool, _MyDependenceToken, @guaranteed MyArray<MyInt>) -> @out MyInt
|
|
%32 = apply %31(%26, %12, %28, %30, %7) : $@convention(method) (MyInt, MyBool, _MyDependenceToken, @guaranteed MyArray<MyInt>) -> @out MyInt
|
|
%35 = alloc_stack $MyInt
|
|
debug_value %16 : $MyInt
|
|
debug_value %7 : $MyArray<MyInt>
|
|
debug_value %28 : $MyBool
|
|
strong_retain %25 : $Builtin.BridgeObject
|
|
%36 = apply %29(%16, %28, %7) : $@convention(method) (MyInt, MyBool, @guaranteed MyArray<MyInt>) -> _MyDependenceToken
|
|
debug_value %36 : $_MyDependenceToken
|
|
%37 = apply %31(%35, %16, %28, %36, %7) : $@convention(method) (MyInt, MyBool, _MyDependenceToken, @guaranteed MyArray<MyInt>) -> @out MyInt
|
|
strong_release %25 : $Builtin.BridgeObject
|
|
%44 = alloc_stack $MyInt
|
|
debug_value %7 : $MyArray<MyInt>
|
|
debug_value %28 : $MyBool
|
|
strong_retain %25 : $Builtin.BridgeObject
|
|
%45 = apply %29(%20, %28, %7) : $@convention(method) (MyInt, MyBool, @guaranteed MyArray<MyInt>) -> _MyDependenceToken
|
|
debug_value %45 : $_MyDependenceToken
|
|
%46 = apply %31(%44, %20, %28, %45, %7) : $@convention(method) (MyInt, MyBool, _MyDependenceToken, @guaranteed MyArray<MyInt>) -> @out MyInt
|
|
strong_release %25 : $Builtin.BridgeObject
|
|
%52 = tuple ()
|
|
dealloc_stack %44 : $*MyInt
|
|
dealloc_stack %35 : $*MyInt
|
|
dealloc_stack %26 : $*MyInt
|
|
strong_release %25 : $Builtin.BridgeObject
|
|
return %52 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil @propagate_with_get_element_returning_direct_result
|
|
// CHECK: struct $MyInt
|
|
// CHECK: [[V0:%.*]] = integer_literal $Builtin.Int64, 0
|
|
// CHECK: [[I0:%.*]] = struct $MyInt ([[V0]] : $Builtin.Int64)
|
|
// CHECK: [[V1:%.*]] = integer_literal $Builtin.Int64, 1
|
|
// CHECK: [[I1:%.*]] = struct $MyInt ([[V1]] : $Builtin.Int64)
|
|
// CHECK: [[V2:%.*]] = integer_literal $Builtin.Int64, 2
|
|
// CHECK: [[I2:%.*]] = struct $MyInt ([[V2]] : $Builtin.Int64)
|
|
// CHECK: [[S0:%.*]] = alloc_stack $MyInt
|
|
// CHECK: [[HFUN:%.*]] = function_ref @hoistableIsNativeTypeChecked
|
|
// CHECK-NOT: apply [[HFUN]]
|
|
// CHECK: [[CFUN:%.*]] = function_ref @checkSubscript
|
|
// CHECK-NOT: apply [[CFUN]]
|
|
// CHECK: [[GFUN:%.*]] = function_ref @getElement
|
|
// CHECK-NOT: apply [[GFUN]]
|
|
// CHECK-NOT: apply [[HFUN]]
|
|
// CHECK-NOT: apply [[CFUN]]
|
|
// CHECK-NOT: apply [[GFUN]]
|
|
// CHECK: store [[I0]] to [[S0]]
|
|
// CHECK: [[S1:%.*]] = alloc_stack $MyInt
|
|
// CHECK: store [[I1]] to [[S1]]
|
|
// CHECK: [[S2:%.*]] = alloc_stack $MyInt
|
|
// CHECK: store [[I2]] to [[S2]]
|
|
// CHECK: return
|
|
|
|
sil @propagate_with_get_element_returning_direct_result : $@convention(thin) () -> () {
|
|
%0 = function_ref @swift_bufferAllocate : $@convention(thin) () -> @owned AnyObject
|
|
%1 = integer_literal $Builtin.Int64, 3
|
|
%2 = struct $MyInt (%1 : $Builtin.Int64)
|
|
%3 = apply %0() : $@convention(thin) () -> @owned AnyObject
|
|
%4 = metatype $@thin MyArray<MyInt>.Type
|
|
%5 = function_ref @adoptStorage : $@convention(thin) (@owned AnyObject, MyInt, @thin MyArray<MyInt>.Type) -> @owned (MyArray<MyInt>, UnsafeMutablePointer<MyInt>)
|
|
%6 = apply %5(%3, %2, %4) : $@convention(thin) (@owned AnyObject, MyInt, @thin MyArray<MyInt>.Type) -> @owned (MyArray<MyInt>, UnsafeMutablePointer<MyInt>)
|
|
%7 = tuple_extract %6 : $(MyArray<MyInt>, UnsafeMutablePointer<MyInt>), 0
|
|
%8 = tuple_extract %6 : $(MyArray<MyInt>, UnsafeMutablePointer<MyInt>), 1
|
|
debug_value %7 : $MyArray<MyInt>
|
|
debug_value %8 : $UnsafeMutablePointer<MyInt>
|
|
%9 = struct_extract %8 : $UnsafeMutablePointer<MyInt>, #UnsafeMutablePointer._rawValue
|
|
%10 = pointer_to_address %9 : $Builtin.RawPointer to [strict] $*MyInt
|
|
%11 = integer_literal $Builtin.Int64, 0
|
|
%12 = struct $MyInt (%11 : $Builtin.Int64)
|
|
store %12 to %10 : $*MyInt
|
|
%13 = integer_literal $Builtin.Word, 1
|
|
%14 = index_addr %10 : $*MyInt, %13 : $Builtin.Word
|
|
%15 = integer_literal $Builtin.Int64, 1
|
|
%16 = struct $MyInt (%15 : $Builtin.Int64)
|
|
store %16 to %14 : $*MyInt
|
|
%17 = integer_literal $Builtin.Word, 2
|
|
%18 = index_addr %10 : $*MyInt, %17 : $Builtin.Word
|
|
%19 = integer_literal $Builtin.Int64, 2
|
|
%20 = struct $MyInt (%19 : $Builtin.Int64)
|
|
store %20 to %18 : $*MyInt
|
|
%23 = struct_extract %7 : $MyArray<MyInt>, #MyArray._buffer
|
|
%24 = struct_extract %23 : $_MyArrayBuffer<MyInt>, #_MyArrayBuffer._storage
|
|
%25 = struct_extract %24 : $_MyBridgeStorage, #_MyBridgeStorage.rawValue
|
|
%26 = alloc_stack $MyInt
|
|
debug_value %7 : $MyArray<MyInt>
|
|
%27 = function_ref @hoistableIsNativeTypeChecked : $@convention(method) (@guaranteed MyArray<MyInt>) -> MyBool
|
|
%28 = apply %27(%7) : $@convention(method) (@guaranteed MyArray<MyInt>) -> MyBool
|
|
debug_value %28 : $MyBool // id: %104
|
|
%29 = function_ref @checkSubscript : $@convention(method) (MyInt, MyBool, @guaranteed MyArray<MyInt>) -> _MyDependenceToken
|
|
%30 = apply %29(%12, %28, %7) : $@convention(method) (MyInt, MyBool, @guaranteed MyArray<MyInt>) -> _MyDependenceToken
|
|
debug_value %30 : $_MyDependenceToken
|
|
%31 = function_ref @getElement2 : $@convention(method) (MyInt, MyBool, _MyDependenceToken, @guaranteed MyArray<MyInt>) -> MyInt
|
|
%32 = apply %31(%12, %28, %30, %7) : $@convention(method) (MyInt, MyBool, _MyDependenceToken, @guaranteed MyArray<MyInt>) -> MyInt
|
|
store %32 to %26 : $*MyInt
|
|
%35 = alloc_stack $MyInt
|
|
debug_value %16 : $MyInt
|
|
debug_value %7 : $MyArray<MyInt>
|
|
debug_value %28 : $MyBool
|
|
strong_retain %25 : $Builtin.BridgeObject
|
|
%36 = apply %29(%16, %28, %7) : $@convention(method) (MyInt, MyBool, @guaranteed MyArray<MyInt>) -> _MyDependenceToken
|
|
debug_value %36 : $_MyDependenceToken
|
|
%37 = apply %31(%16, %28, %36, %7) : $@convention(method) (MyInt, MyBool, _MyDependenceToken, @guaranteed MyArray<MyInt>) -> MyInt
|
|
store %37 to %35 : $*MyInt
|
|
strong_release %25 : $Builtin.BridgeObject
|
|
%44 = alloc_stack $MyInt
|
|
debug_value %7 : $MyArray<MyInt>
|
|
debug_value %28 : $MyBool
|
|
strong_retain %25 : $Builtin.BridgeObject
|
|
%45 = apply %29(%20, %28, %7) : $@convention(method) (MyInt, MyBool, @guaranteed MyArray<MyInt>) -> _MyDependenceToken
|
|
debug_value %45 : $_MyDependenceToken
|
|
%46 = apply %31(%20, %28, %45, %7) : $@convention(method) (MyInt, MyBool, _MyDependenceToken, @guaranteed MyArray<MyInt>) -> MyInt
|
|
store %46 to %44 : $*MyInt
|
|
strong_release %25 : $Builtin.BridgeObject
|
|
%52 = tuple ()
|
|
dealloc_stack %44 : $*MyInt
|
|
dealloc_stack %35 : $*MyInt
|
|
dealloc_stack %26 : $*MyInt
|
|
strong_release %25 : $Builtin.BridgeObject
|
|
return %52 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil @repeated_initialization
|
|
// CHECK: [[GFUN:%.*]] = function_ref @getElement
|
|
// CHECK: apply [[GFUN]]
|
|
// CHECK: apply [[GFUN]]
|
|
// CHECK: return
|
|
|
|
sil @repeated_initialization : $@convention(thin) () -> () {
|
|
%0 = function_ref @swift_bufferAllocate : $@convention(thin) () -> @owned AnyObject
|
|
%1 = integer_literal $Builtin.Int64, 2
|
|
%2 = struct $MyInt (%1 : $Builtin.Int64)
|
|
%3 = apply %0() : $@convention(thin) () -> @owned AnyObject
|
|
%4 = metatype $@thin MyArray<MyInt>.Type
|
|
%5 = function_ref @adoptStorage : $@convention(thin) (@owned AnyObject, MyInt, @thin MyArray<MyInt>.Type) -> @owned (MyArray<MyInt>, UnsafeMutablePointer<MyInt>)
|
|
%6 = apply %5(%3, %2, %4) : $@convention(thin) (@owned AnyObject, MyInt, @thin MyArray<MyInt>.Type) -> @owned (MyArray<MyInt>, UnsafeMutablePointer<MyInt>)
|
|
%7 = tuple_extract %6 : $(MyArray<MyInt>, UnsafeMutablePointer<MyInt>), 0
|
|
%8 = tuple_extract %6 : $(MyArray<MyInt>, UnsafeMutablePointer<MyInt>), 1
|
|
%9 = struct_extract %8 : $UnsafeMutablePointer<MyInt>, #UnsafeMutablePointer._rawValue
|
|
%10 = pointer_to_address %9 : $Builtin.RawPointer to [strict] $*MyInt
|
|
%11 = integer_literal $Builtin.Int64, 0
|
|
%12 = struct $MyInt (%11 : $Builtin.Int64)
|
|
store %12 to %10 : $*MyInt
|
|
%13 = integer_literal $Builtin.Word, 0
|
|
%14 = index_addr %10 : $*MyInt, %13 : $Builtin.Word
|
|
%15 = integer_literal $Builtin.Int64, 1
|
|
%16 = struct $MyInt (%15 : $Builtin.Int64)
|
|
store %16 to %14 : $*MyInt
|
|
%23 = struct_extract %7 : $MyArray<MyInt>, #MyArray._buffer
|
|
%24 = struct_extract %23 : $_MyArrayBuffer<MyInt>, #_MyArrayBuffer._storage
|
|
%25 = struct_extract %24 : $_MyBridgeStorage, #_MyBridgeStorage.rawValue
|
|
%26 = alloc_stack $MyInt
|
|
%27 = function_ref @hoistableIsNativeTypeChecked : $@convention(method) (@guaranteed MyArray<MyInt>) -> MyBool
|
|
%28 = apply %27(%7) : $@convention(method) (@guaranteed MyArray<MyInt>) -> MyBool
|
|
%29 = function_ref @checkSubscript : $@convention(method) (MyInt, MyBool, @guaranteed MyArray<MyInt>) -> _MyDependenceToken
|
|
%30 = apply %29(%12, %28, %7) : $@convention(method) (MyInt, MyBool, @guaranteed MyArray<MyInt>) -> _MyDependenceToken
|
|
%31 = function_ref @getElement : $@convention(method) (MyInt, MyBool, _MyDependenceToken, @guaranteed MyArray<MyInt>) -> @out MyInt
|
|
%32 = apply %31(%26, %12, %28, %30, %7) : $@convention(method) (MyInt, MyBool, _MyDependenceToken, @guaranteed MyArray<MyInt>) -> @out MyInt
|
|
%35 = alloc_stack $MyInt
|
|
strong_retain %25 : $Builtin.BridgeObject
|
|
%36 = apply %29(%16, %28, %7) : $@convention(method) (MyInt, MyBool, @guaranteed MyArray<MyInt>) -> _MyDependenceToken
|
|
%37 = apply %31(%35, %16, %28, %36, %7) : $@convention(method) (MyInt, MyBool, _MyDependenceToken, @guaranteed MyArray<MyInt>) -> @out MyInt
|
|
strong_release %25 : $Builtin.BridgeObject
|
|
%52 = tuple ()
|
|
dealloc_stack %35 : $*MyInt
|
|
dealloc_stack %26 : $*MyInt
|
|
strong_release %25 : $Builtin.BridgeObject
|
|
return %52 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil @unknown_use
|
|
// CHECK: [[GFUN:%.*]] = function_ref @getElement
|
|
// CHECK: apply [[GFUN]]
|
|
// CHECK: return
|
|
|
|
sil @unknown_use : $@convention(thin) () -> () {
|
|
%0 = function_ref @swift_bufferAllocate : $@convention(thin) () -> @owned AnyObject
|
|
%1 = integer_literal $Builtin.Int64, 2
|
|
%2 = struct $MyInt (%1 : $Builtin.Int64)
|
|
%3 = apply %0() : $@convention(thin) () -> @owned AnyObject
|
|
%4 = metatype $@thin MyArray<MyInt>.Type
|
|
%5 = function_ref @adoptStorage : $@convention(thin) (@owned AnyObject, MyInt, @thin MyArray<MyInt>.Type) -> @owned (MyArray<MyInt>, UnsafeMutablePointer<MyInt>)
|
|
%6 = apply %5(%3, %2, %4) : $@convention(thin) (@owned AnyObject, MyInt, @thin MyArray<MyInt>.Type) -> @owned (MyArray<MyInt>, UnsafeMutablePointer<MyInt>)
|
|
%7 = tuple_extract %6 : $(MyArray<MyInt>, UnsafeMutablePointer<MyInt>), 0
|
|
%8 = tuple_extract %6 : $(MyArray<MyInt>, UnsafeMutablePointer<MyInt>), 1
|
|
%9 = struct_extract %8 : $UnsafeMutablePointer<MyInt>, #UnsafeMutablePointer._rawValue
|
|
%10 = pointer_to_address %9 : $Builtin.RawPointer to [strict] $*MyInt
|
|
%11 = integer_literal $Builtin.Int64, 0
|
|
%12 = struct $MyInt (%11 : $Builtin.Int64)
|
|
store %12 to %10 : $*MyInt
|
|
%23 = struct_extract %7 : $MyArray<MyInt>, #MyArray._buffer
|
|
%24 = struct_extract %23 : $_MyArrayBuffer<MyInt>, #_MyArrayBuffer._storage
|
|
%25 = struct_extract %24 : $_MyBridgeStorage, #_MyBridgeStorage.rawValue
|
|
%26 = alloc_stack $MyInt
|
|
%27 = function_ref @hoistableIsNativeTypeChecked : $@convention(method) (@guaranteed MyArray<MyInt>) -> MyBool
|
|
%28 = apply %27(%7) : $@convention(method) (@guaranteed MyArray<MyInt>) -> MyBool
|
|
%29 = function_ref @checkSubscript : $@convention(method) (MyInt, MyBool, @guaranteed MyArray<MyInt>) -> _MyDependenceToken
|
|
%30 = apply %29(%12, %28, %7) : $@convention(method) (MyInt, MyBool, @guaranteed MyArray<MyInt>) -> _MyDependenceToken
|
|
%31 = function_ref @getElement : $@convention(method) (MyInt, MyBool, _MyDependenceToken, @guaranteed MyArray<MyInt>) -> @out MyInt
|
|
%32 = apply %31(%26, %12, %28, %30, %7) : $@convention(method) (MyInt, MyBool, _MyDependenceToken, @guaranteed MyArray<MyInt>) -> @out MyInt
|
|
%33 = function_ref @unknown_array_use : $@convention(method) (@guaranteed MyArray<MyInt>) -> MyBool
|
|
%34 = apply %33(%7) : $@convention(method) (@guaranteed MyArray<MyInt>) -> MyBool
|
|
%52 = tuple ()
|
|
dealloc_stack %26 : $*MyInt
|
|
strong_release %25 : $Builtin.BridgeObject
|
|
return %52 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil @append_contentsOf_int
|
|
// CHECK: [[ASFUN:%.*]] = function_ref @arrayAdoptStorage
|
|
// CHECK-NEXT: [[ARR:%.*]] = apply [[ASFUN]]
|
|
// CHECK-NEXT: [[OWNER:%.*]] = tuple_extract [[ARR]]{{.*}}, 0
|
|
// CHECK-NOT: apply [[ACFUN]]
|
|
// CHECK: [[AEFUN:%.*]] = function_ref @_T0Sa6appendyyxF
|
|
// CHECK-NEXT: [[STACK:%.*]] = alloc_stack $MyInt
|
|
// CHECK-NEXT: store %{{[0-9]+}} to [[STACK]]
|
|
// CHECK-NEXT: apply [[AEFUN]]<MyInt>([[STACK]]
|
|
// CHECK-NEXT: dealloc_stack [[STACK]]
|
|
// CHECK-NEXT: release_value [[OWNER]]
|
|
// CHECK: return
|
|
sil @append_contentsOf_int : $@convention(thin) () -> () {
|
|
%0 = function_ref @swift_bufferAllocate : $@convention(thin) () -> @owned AnyObject
|
|
%1 = integer_literal $Builtin.Int64, 1
|
|
%2 = struct $MyInt (%1 : $Builtin.Int64)
|
|
%3 = apply %0() : $@convention(thin) () -> @owned AnyObject
|
|
%4 = metatype $@thin Array<MyInt>.Type
|
|
%5 = function_ref @arrayAdoptStorage : $@convention(thin) (@owned AnyObject, MyInt, @thin Array<MyInt>.Type) -> @owned (Array<MyInt>, UnsafeMutablePointer<MyInt>)
|
|
%6 = apply %5(%3, %2, %4) : $@convention(thin) (@owned AnyObject, MyInt, @thin Array<MyInt>.Type) -> @owned (Array<MyInt>, UnsafeMutablePointer<MyInt>)
|
|
%7 = tuple_extract %6 : $(Array<MyInt>, UnsafeMutablePointer<MyInt>), 0
|
|
%8 = tuple_extract %6 : $(Array<MyInt>, UnsafeMutablePointer<MyInt>), 1
|
|
%9 = struct_extract %8 : $UnsafeMutablePointer<MyInt>, #UnsafeMutablePointer._rawValue
|
|
%10 = pointer_to_address %9 : $Builtin.RawPointer to [strict] $*MyInt
|
|
%11 = integer_literal $Builtin.Int64, 27
|
|
%12 = struct $MyInt (%11 : $Builtin.Int64)
|
|
store %12 to %10 : $*MyInt
|
|
%13 = alloc_stack $Array<MyInt>
|
|
%14 = metatype $@thin Array<MyInt>.Type
|
|
%15 = function_ref @arrayInit : $@convention(method) (@thin Array<MyInt>.Type) -> @owned Array<MyInt>
|
|
%16 = apply %15(%14) : $@convention(method) (@thin Array<MyInt>.Type) -> @owned Array<MyInt>
|
|
store %16 to %13 : $*Array<MyInt>
|
|
%17 = function_ref @arrayAppendContentsOf : $@convention(method) (@owned Array<MyInt>, @inout Array<MyInt>) -> ()
|
|
%18 = apply %17(%7, %13) : $@convention(method) (@owned Array<MyInt>, @inout Array<MyInt>) -> ()
|
|
dealloc_stack %13 : $*Array<MyInt>
|
|
%19 = tuple ()
|
|
return %19 : $()
|
|
}
|
|
|
|
class Hello {
|
|
}
|
|
|
|
sil [_semantics "array.uninitialized"] @adoptStorageHello : $@convention(method) (@owned _ContiguousArrayStorage<Hello>, MyInt, @thin Array<Hello>.Type) -> (@owned Array<Hello>, UnsafeMutablePointer<Hello>)
|
|
sil [_semantics "array.append_contentsOf"] @arrayAppendContentsOfHello : $@convention(method) (@owned Array<Hello>, @inout Array<Hello>) -> ()
|
|
|
|
// CHECK-LABEL: sil @append_contentsOf_class
|
|
// CHECK: [[ASFUN:%.*]] = function_ref @adoptStorageHello
|
|
// CHECK-NEXT: [[ARR:%.*]] = apply [[ASFUN]]
|
|
// CHECK-NEXT: [[OWNER:%.*]] = tuple_extract [[ARR]]{{.*}}, 0
|
|
// CHECK: strong_retain %1 : $Hello
|
|
// CHECK-NEXT: store %1 to %{{[0-9]+}} : $*Hello
|
|
// CHECK-NOT: apply
|
|
// CHECK: [[AEFUN:%.*]] = function_ref @_T0Sa6appendyyxF
|
|
// CHECK-NEXT: strong_retain %1 : $Hello
|
|
// CHECK-NEXT: [[STACK:%.*]] = alloc_stack $Hello
|
|
// CHECK-NEXT: store %1 to [[STACK]]
|
|
// CHECK-NEXT: apply [[AEFUN]]<Hello>([[STACK]], %0)
|
|
// CHECK-NEXT: dealloc_stack [[STACK]]
|
|
// CHECK-NEXT: release_value [[OWNER]]
|
|
// CHECK-NEXT: return
|
|
sil @append_contentsOf_class : $@convention(thin) (@inout Array<Hello>, @owned Hello) -> @owned Hello {
|
|
bb0(%0 : $*Array<Hello>, %1 : $Hello):
|
|
%4 = integer_literal $Builtin.Word, 1
|
|
%5 = integer_literal $Builtin.Int64, 1
|
|
%6 = struct $MyInt (%5 : $Builtin.Int64)
|
|
%7 = alloc_ref [tail_elems $Hello * %4 : $Builtin.Word] $_ContiguousArrayStorage<Hello>
|
|
%8 = metatype $@thin Array<Hello>.Type
|
|
%9 = function_ref @adoptStorageHello : $@convention(method) (@owned _ContiguousArrayStorage<Hello>, MyInt, @thin Array<Hello>.Type) -> (@owned Array<Hello>, UnsafeMutablePointer<Hello>)
|
|
%10 = apply %9(%7, %6, %8) : $@convention(method) (@owned _ContiguousArrayStorage<Hello>, MyInt, @thin Array<Hello>.Type) -> (@owned Array<Hello>, UnsafeMutablePointer<Hello>)
|
|
%11 = tuple_extract %10 : $(Array<Hello>, UnsafeMutablePointer<Hello>), 0
|
|
%12 = tuple_extract %10 : $(Array<Hello>, UnsafeMutablePointer<Hello>), 1
|
|
%13 = struct_extract %12 : $UnsafeMutablePointer<Hello>, #UnsafeMutablePointer._rawValue
|
|
%22 = pointer_to_address %13 : $Builtin.RawPointer to [strict] $*Hello
|
|
strong_retain %1 : $Hello
|
|
store %1 to %22 : $*Hello
|
|
%25 = function_ref @arrayAppendContentsOfHello : $@convention(method) (@owned Array<Hello>, @inout Array<Hello>) -> ()
|
|
%26 = apply %25(%11, %0) : $@convention(method) (@owned Array<Hello>, @inout Array<Hello>) -> ()
|
|
return %1 : $Hello
|
|
}
|