blob: 37b31356b9eedd8105b2cb4931a6531f6c481875 [file] [log] [blame]
// RUN: %target-sil-opt -enable-sil-opaque-values -enable-sil-verify-all=0 -module-name Swift -o /dev/null 2>&1 %s
// REQUIRES: asserts
// This file is meant to contain tests that previously the verifier treated
// incorrectly. This is important to ensure that the verifier does not
// regress. It should only deal with use matching of opaque types.
sil_stage canonical
import Builtin
sil [ossa] @unconditional_checked_cast_value_test : $@convention(thin) <T> (Builtin.Int32) -> @out T {
bb0(%0 : $Builtin.Int32):
%1 = unconditional_checked_cast_value %0 : $Builtin.Int32 to $T
return %1 : $T
}
sil [ossa] @opaque_identity : $@convention(thin) <T> (@in T) -> @out T {
bb0(%0 : @owned $T):
return %0 : $T
}
sil [ossa] @opaque_copy : $@convention(thin) <T> (@in_guaranteed T) -> @out T {
bb0(%0 : @guaranteed $T):
%1 = copy_value %0 : $T
return %1 : $T
}
sil [ossa] @opaque_arg_copy : $@convention(thin) <T> (@in T) -> @out T {
bb0(%0 : @owned $T):
%1 = begin_borrow %0 : $T
%2 = copy_value %1 : $T
%9 = function_ref @opaque_identity : $@convention(thin) <T> (@in T) -> @out T
%11 = apply %9<T>(%2) : $@convention(thin) _0_0> (@in τ_0_0) -> @out τ_0_0
end_borrow %1 : $T
destroy_value %0 : $T
return %11 : $T
}
sil [ossa] @opaque_arg_borrow : $@convention(thin) <T> (@in T) -> @out T {
bb0(%0 : @owned $T):
%1 = begin_borrow %0 : $T
%9 = function_ref @opaque_copy : $@convention(thin) <T> (@in_guaranteed T) -> @out T
%11 = apply %9<T>(%1) : $@convention(thin) _0_0> (@in_guaranteed τ_0_0) -> @out τ_0_0
end_borrow %1 : $T
destroy_value %0 : $T
return %11 : $T
}
sil [ossa] @opaque_arg_guaranteed : $@convention(thin) <T> (@in_guaranteed T) -> @out T {
bb0(%0 : @guaranteed $T):
%1 = copy_value %0 : $T
%2 = begin_borrow %1 : $T
%3 = function_ref @opaque_copy : $@convention(thin) <T> (@in_guaranteed T) -> @out T
%4 = apply %3<T>(%2) : $@convention(thin) <T> (@in_guaranteed T) -> @out T
end_borrow %2 : $T
destroy_value %1 : $T
return %4 : $T
}
typealias AnyObject = Builtin.AnyObject
sil [ossa] @takeType : $@convention(thin) (@thick AnyObject.Type) -> () {
bb0(%0 : $@thick AnyObject.Type):
%18 = tuple ()
return %18 : $()
}
// Test an unconditional cast from an owned value to a trivial value.
sil [ossa] @castToTrivial : $@convention(thin) (@owned AnyObject) -> () {
bb0(%0 : @owned $AnyObject):
%6 = function_ref @takeType : $@convention(thin) (@thick AnyObject.Type) -> ()
%8 = begin_borrow %0 : $AnyObject
%9 = copy_value %8 : $AnyObject
%10 = unconditional_checked_cast_value %9 : $AnyObject to $@thick AnyObject.Type
%11 = apply %6(%10) : $@convention(thin) (@thick AnyObject.Type) -> ()
end_borrow %8 : $AnyObject
destroy_value %0 : $AnyObject
%18 = tuple ()
return %18 : $()
}
sil [ossa] @passTrivialAsOpaqueValue : $@convention(thin) (Builtin.Int64) -> () {
bb0(%0 : $Builtin.Int64):
%1 = function_ref @opaque_copy : $@convention(thin) <T> (@in_guaranteed T) -> @out T
%2 = apply %1<Builtin.Int64>(%0) : $@convention(thin) <T> (@in_guaranteed T) -> @out T
%3 = function_ref @opaque_arg_copy : $@convention(thin) <T> (@in T) -> @out T
apply %3<Builtin.Int64>(%0) : $@convention(thin) <T> (@in T) -> @out T
%9999 = tuple()
return %9999 : $()
}