1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
// RUN: %target-sil-opt -definite-init %s | %FileCheck %s
// Make sure that DI properly converts mark_unresolved_non_copyable_value
// [assignable_but_not_consumable] -> mark_unresolved_non_copyable_value
// [initable_but_not_consumable].
sil_stage raw
import Swift
fileprivate final class _Box<T> {
var value: _Node<T>
init(_ value: consuming _Node<T>)
}
struct _Node<T> : ~Copyable {
var value: T
var _next: ListEntry<T>
init(_ newValue: T)
}
struct ListEntry<T> : ~Copyable {
private var innerBox: _Box<T>
}
// CHECK-LABEL: sil private [ossa] @boxInit : $@convention(method) <T> (@in _Node<T>, @owned _Box<T>) -> @owned _Box<T> {
// CHECK: bb0([[INPUT:%.*]] : $*_Node<T>, %1 : @owned
// CHECK: [[SELF:%.*]] = mark_uninitialized [rootself] %1
// CHECK: [[BORROW_SELF:%.*]] = begin_borrow [[SELF]]
// CHECK: [[REF:%.*]] = ref_element_addr [[BORROW_SELF]]
// CHECK: [[ACCESS:%.*]] = begin_access [modify] [dynamic] [[REF]]
// CHECK: [[MARK:%.*]] = mark_unresolved_non_copyable_value [initable_but_not_consumable] [[ACCESS]]
// CHECK: copy_addr [take] {{%.*}} to [init] [[MARK]]
// CHECK: end_access [[ACCESS]]
// CHECK: } // end sil function 'boxInit'
sil private [ossa] @boxInit : $@convention(method) <T> (@in _Node<T>, @owned _Box<T>) -> @owned _Box<T> {
bb0(%0 : $*_Node<T>, %1 : @owned $_Box<T>):
%2 = alloc_stack [lexical] $_Node<T>, var, name "value"
%3 = mark_unresolved_non_copyable_value [consumable_and_assignable] %2 : $*_Node<T>
copy_addr [take] %0 to [init] %3 : $*_Node<T>
debug_value %1 : $_Box<T>, let, name "self", argno 2
%6 = mark_uninitialized [rootself] %1 : $_Box<T>
%7 = begin_borrow %6 : $_Box<T>
%8 = begin_access [read] [static] %3 : $*_Node<T>
%9 = alloc_stack $_Node<T>
copy_addr %8 to [init] %9 : $*_Node<T>
end_access %8 : $*_Node<T>
%12 = ref_element_addr %7 : $_Box<T>, #_Box.value
%13 = begin_access [modify] [dynamic] %12 : $*_Node<T>
%14 = mark_unresolved_non_copyable_value [assignable_but_not_consumable] %13 : $*_Node<T>
copy_addr [take] %9 to %14 : $*_Node<T>
end_access %13 : $*_Node<T>
dealloc_stack %9 : $*_Node<T>
end_borrow %7 : $_Box<T>
%19 = copy_value %6 : $_Box<T>
destroy_value %6 : $_Box<T>
destroy_addr %3 : $*_Node<T>
dealloc_stack %2 : $*_Node<T>
return %19 : $_Box<T>
}
|