mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Type annotations for instruction operands are omitted, e.g. ``` %3 = struct $S(%1, %2) ``` Operand types are redundant anyway and were only used for sanity checking in the SIL parser. But: operand types _are_ printed if the definition of the operand value was not printed yet. This happens: * if the block with the definition appears after the block where the operand's instruction is located * if a block or instruction is printed in isolation, e.g. in a debugger The old behavior can be restored with `-Xllvm -sil-print-types`. This option is added to many existing test files which check for operand types in their check-lines.
54 lines
2.8 KiB
Swift
54 lines
2.8 KiB
Swift
// RUN: %target-swift-emit-silgen -Xllvm -sil-print-types %s | %FileCheck %s
|
|
|
|
// Make sure we do not call the getter to get the oldValue and pass it to didSet
|
|
// when the didSet does not reference the oldValue in its body.
|
|
|
|
class Foo<T> {
|
|
var value: T {
|
|
// CHECK-LABEL: sil private [ossa] @$s35didset_oldvalue_not_accessed_silgen3FooC5valuexvW : $@convention(method) <T> (@guaranteed Foo<T>) -> ()
|
|
// CHECK: debug_value %0 : $Foo<T>, let, name "self", argno {{[0-9]+}}
|
|
// CHECK-NOT: debug_value %0 : $*T, let, name "oldValue", argno {{[0-9]+}}, {{.*}} expr op_deref
|
|
didSet { print("didSet called!") }
|
|
}
|
|
|
|
init(value: T) {
|
|
self.value = value
|
|
}
|
|
}
|
|
|
|
let foo = Foo(value: "Hello")
|
|
// Foo.value.setter //
|
|
|
|
// CHECK-LABEL: sil hidden [ossa] @$s35didset_oldvalue_not_accessed_silgen3FooC5valuexvs : $@convention(method) <T> (@in T, @guaranteed Foo<T>) -> ()
|
|
// CHECK: debug_value [[VALUE:%.*]] : $*T, let, name "value", argno {{[0-9+]}}, expr op_deref
|
|
// CHECK-NEXT: debug_value [[SELF:%.*]] : $Foo<T>, let, name "self", argno {{[0-9+]}}
|
|
// CHECK-NEXT: [[ALLOC_STACK:%.*]] = alloc_stack $T
|
|
// CHECK-NEXT: copy_addr [[VALUE]] to [init] [[ALLOC_STACK]] : $*T
|
|
// CHECK-NEXT: [[REF_ADDR:%.*]] = ref_element_addr [[SELF]] : $Foo<T>, #Foo.value
|
|
// CHECK-NEXT: [[BEGIN_ACCESS:%.*]] = begin_access [modify] [dynamic] [[REF_ADDR]] : $*T
|
|
// CHECK-NEXT: copy_addr [take] [[ALLOC_STACK]] to [[BEGIN_ACCESS]] : $*T
|
|
// CHECK-NEXT: end_access [[BEGIN_ACCESS]] : $*T
|
|
// CHECK-NEXT: dealloc_stack [[ALLOC_STACK]] : $*T
|
|
|
|
// CHECK: [[DIDSET:%.*]] = function_ref @$s35didset_oldvalue_not_accessed_silgen3FooC5valuexvW : $@convention(method) <τ_0_0> (@guaranteed Foo<τ_0_0>) -> ()
|
|
// CHECK-NEXT: [[RESULT:%.*]] = apply [[DIDSET]]<T>([[SELF]]) : $@convention(method) <τ_0_0> (@guaranteed Foo<τ_0_0>) -> ()
|
|
|
|
// Foo.value.modify //
|
|
|
|
// CHECK-LABEL: sil hidden [ossa] @$s35didset_oldvalue_not_accessed_silgen3FooC5valuexvM : $@yield_once @convention(method) <T> (@guaranteed Foo<T>) -> @yields @inout T
|
|
// CHECK: debug_value [[SELF:%.*]] : $Foo<T>, let, name "self", argno {{[0-9+]}}
|
|
// CHECK-NEXT: [[REF_ADDR:%.*]] = ref_element_addr [[SELF]] : $Foo<T>, #Foo.value
|
|
// CHECK-NEXT: [[BEGIN_ACCESS:%.*]] = begin_access [modify] [dynamic] [[REF_ADDR]] : $*T
|
|
// CHECK-NEXT: yield [[BEGIN_ACCESS]] : $*T, resume bb1, unwind bb2
|
|
|
|
// CHECK: bb1:
|
|
// CHECK-NEXT: end_access [[BEGIN_ACCESS]] : $*T
|
|
// CHECK-NEXT: // function_ref Foo.value.didset
|
|
// CHECK-NEXT: [[DIDSET:%.*]] = function_ref @$s35didset_oldvalue_not_accessed_silgen3FooC5valuexvW : $@convention(method) <τ_0_0> (@guaranteed Foo<τ_0_0>) -> ()
|
|
// CHECK-NEXT: [[RESULT:%.*]] = apply [[DIDSET]]<T>([[SELF]]) : $@convention(method) <τ_0_0> (@guaranteed Foo<τ_0_0>) -> ()
|
|
|
|
// CHECK: bb2:
|
|
// CHECK-NEXT: end_access [[BEGIN_ACCESS]] : $*T
|
|
// CHECK-NEXT: unwind
|
|
foo.value = "World"
|