mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
We do this since we need to be able to handle instructions that may have two different results that independently need their scopes lifetime to be ended.
107 lines
4.2 KiB
Plaintext
107 lines
4.2 KiB
Plaintext
// RUN: %target-sil-opt -sil-verify-all=false -enable-sil-verify-all=false -emit-sorted-sil -verify-continue-on-failure -o /dev/null %s 2>&1 | %FileCheck '--implicit-check-not=Begin Error' %s
|
|
|
|
// NOTE: We run the verification when we parse. We turn off sil-verify-all so
|
|
// that we do not emit the diagnostics a second time after sil-opt ends. We do
|
|
// this so that we can use an implicit-check-not line to make sure that
|
|
// additional diagnostics are not emitted.
|
|
|
|
// REQUIRES: asserts
|
|
|
|
sil_stage canonical
|
|
|
|
import Builtin
|
|
|
|
class C {}
|
|
|
|
protocol Error {}
|
|
|
|
// CHECK-LABEL: Begin Error in function end_borrow_1_addr_alloc_stack
|
|
// CHECK: SIL verification failed: end_borrow of an address not produced by store_borrow
|
|
// CHECK-LABEL: End Error in function end_borrow_1_addr_alloc_stack
|
|
sil [ossa] @end_borrow_1_addr_alloc_stack : $@convention(thin) () -> () {
|
|
%addr = alloc_stack $C
|
|
end_borrow %addr : $*C
|
|
dealloc_stack %addr : $*C
|
|
%retval = tuple ()
|
|
return %retval : $()
|
|
}
|
|
|
|
// CHECK-LABEL: Begin Error in function destroy_value_dead_end
|
|
// CHECK: SIL verification failed: a dead_end destroy_value must be in a dead-end block
|
|
// CHECK: Verifying instruction:
|
|
// CHECK: [[ARGUMENT:%[^,]+]] = argument
|
|
// CHECK: -> destroy_value [dead_end] [[ARGUMENT]]
|
|
// CHECK-LABEL: End Error in function destroy_value_dead_end
|
|
sil [ossa] @destroy_value_dead_end : $@convention(thin) (@owned C) -> () {
|
|
entry(%c : @owned $C):
|
|
destroy_value [dead_end] %c : $C
|
|
%retval = tuple()
|
|
return %retval : $()
|
|
}
|
|
|
|
// CHECK-LABEL: Begin Error in function dealloc_box_dead_end
|
|
// CHECK: SIL verification failed: a dead_end dealloc_box must be in a dead-end block
|
|
// CHECK: Verifying instruction:
|
|
// CHECK: [[BOX:%[^,]+]] = alloc_box
|
|
// CHECK: -> dealloc_box [dead_end] [[BOX]]
|
|
// CHECK-LABEL: End Error in function dealloc_box_dead_end
|
|
sil [ossa] @dealloc_box_dead_end : $@convention(thin) () -> () {
|
|
%b = alloc_box ${ var C }
|
|
dealloc_box [dead_end] %b : ${ var C }
|
|
%retval = tuple()
|
|
return %retval : $()
|
|
}
|
|
|
|
// CHECK-LABEL: Begin Error in function abort_apply_callee_allocated_coro
|
|
// CHECK: SIL verification failed: abort_apply of callee-allocated yield-once coroutine!?
|
|
// CHECK: Verifying instruction:
|
|
// CHECK: ({{%[^,]+}}, **[[TOKEN:%[^,]+]]**, {{%[^,]+}}) = begin_apply
|
|
// CHECK: -> abort_apply [[TOKEN]]
|
|
// CHECK-LABEL: End Error in function abort_apply_callee_allocated_coro
|
|
sil [ossa] @abort_apply_callee_allocated_coro : $@convention(thin) () -> (@error any Error) {
|
|
entry:
|
|
(%value, %token, %allocation) = begin_apply undef() : $@yield_once_2 @convention(thin) () -> @yields @in_guaranteed ()
|
|
try_apply undef() : $@convention(thin) () -> @error any Error, normal success, error failure
|
|
|
|
success(%val : $()):
|
|
end_apply %token as $()
|
|
dealloc_stack %allocation : $*Builtin.SILToken
|
|
return undef : $()
|
|
|
|
failure(%error : @owned $any Error):
|
|
abort_apply %token
|
|
dealloc_stack %allocation : $*Builtin.SILToken
|
|
throw %error : $any Error
|
|
}
|
|
|
|
// CHECK-LABEL: Begin Error in function abort_apply_callee_allocated_coro_2
|
|
// CHECK: SIL verification failed: abort_apply of callee-allocated yield-once coroutine!?: !bai->getSubstCalleeType()->isCalleeAllocatedCoroutine() || AI->getFunction()->getASTContext().LangOpts.hasFeature( Feature::CoroutineAccessorsUnwindOnCallerError)
|
|
// CHECK: End Error in function abort_apply_callee_allocated_coro_2
|
|
sil [ossa] @abort_apply_callee_allocated_coro_2 : $@convention(thin) () -> (@error any Error) {
|
|
entry:
|
|
(%value, %token, %allocation) = begin_apply undef() : $@yield_once_2 @convention(thin) () -> @yields @in_guaranteed ()
|
|
end_apply %token as $()
|
|
dealloc_stack %allocation : $*Builtin.SILToken
|
|
return undef : $()
|
|
|
|
failure(%error : @owned $any Error):
|
|
abort_apply %token
|
|
dealloc_stack %allocation : $*Builtin.SILToken
|
|
throw %error : $any Error
|
|
}
|
|
|
|
sil [ossa] @yield_test : $@yield_once @convention(thin) (@inout Builtin.Int32) -> @yields @inout Builtin.Int32 {
|
|
bb0(%0 : $*Builtin.Int32):
|
|
(%2, %3) = begin_apply undef(%0) : $@yield_once @convention(method) (@inout Builtin.Int32) -> @yields @inout Builtin.Int32
|
|
yield %2, resume bb1, unwind bb2
|
|
|
|
bb1:
|
|
%5 = end_apply %3 as $()
|
|
%6 = tuple ()
|
|
return %6
|
|
|
|
bb2:
|
|
abort_apply %3
|
|
unwind
|
|
}
|