mirror of
https://github.com/apple/swift.git
synced 2026-02-27 18:26:24 +01:00
109 lines
4.3 KiB
Plaintext
109 lines
4.3 KiB
Plaintext
// RUN: %target-sil-opt -sil-opt-remark-ignore-always-infer -assemblyvisionremarkgen-declless-debugvalue-use-sildebugvar-info -assembly-vision-remark-generator -sil-remarks-missed=sil-assembly-vision-remark-gen -verify %s -o /dev/null
|
|
|
|
sil_stage canonical
|
|
|
|
import Builtin
|
|
|
|
//////////////////
|
|
// Declarations //
|
|
//////////////////
|
|
|
|
class Klass {}
|
|
|
|
enum TrivialState {
|
|
case first
|
|
case second
|
|
case third
|
|
}
|
|
|
|
struct StructWithOwner {
|
|
var owner: Klass
|
|
var state: TrivialState
|
|
}
|
|
|
|
struct KlassPair {
|
|
var lhs: Klass
|
|
var rhs: Klass
|
|
}
|
|
|
|
struct StructWithOwnerAndState {
|
|
var structWithOwner: StructWithOwner
|
|
var state: TrivialState
|
|
}
|
|
|
|
struct _SwiftEmptyArrayStorage {
|
|
var nonTrivialField: Klass = Klass()
|
|
}
|
|
|
|
class EmptyArrayStorage {
|
|
var state: TrivialState = .first
|
|
}
|
|
|
|
///////////
|
|
// Tests //
|
|
///////////
|
|
|
|
sil @simple : $@convention(thin) (@guaranteed Builtin.NativeObject) -> () {
|
|
bb0(%0 : $Builtin.NativeObject):
|
|
debug_value %0 : $Builtin.NativeObject, let, name "arg"
|
|
strong_retain %0 : $Builtin.NativeObject // expected-remark {{retain of type 'Builtin.NativeObject'}}
|
|
// expected-note @-2 {{of 'arg'}}
|
|
retain_value %0 : $Builtin.NativeObject // expected-remark {{retain of type 'Builtin.NativeObject'}}
|
|
// expected-note @-4 {{of 'arg'}}
|
|
strong_release %0 : $Builtin.NativeObject // expected-remark {{release of type 'Builtin.NativeObject'}}
|
|
// expected-note @-6 {{of 'arg'}}
|
|
release_value %0 : $Builtin.NativeObject // expected-remark {{release of type 'Builtin.NativeObject'}}
|
|
// expected-note @-8 {{of 'arg'}}
|
|
%9999 = tuple()
|
|
return %9999 : $()
|
|
}
|
|
|
|
sil @extract_out_singleobj_struct_subfield_1 : $@convention(thin) (@guaranteed StructWithOwner) -> Klass {
|
|
bb0(%0 : $StructWithOwner):
|
|
debug_value %0 : $StructWithOwner, let, name "x"
|
|
%1 = struct_extract %0 : $StructWithOwner, #StructWithOwner.owner
|
|
strong_retain %1 : $Klass // expected-remark {{retain of type 'Klass'}}
|
|
// expected-note @-3 {{of 'x.owner'}}
|
|
return %1 : $Klass
|
|
}
|
|
|
|
// This case should never actually happen like this, but we should handle it in
|
|
// a sound way by printing both notes for y and x and also make sure that we do
|
|
// not infer .owner on y since y is on owner itself.
|
|
sil @extract_out_singleobj_struct_subfield_multiple_debugvalue : $@convention(thin) (@guaranteed StructWithOwner) -> Klass {
|
|
bb0(%0 : $StructWithOwner):
|
|
debug_value %0 : $StructWithOwner, let, name "x"
|
|
%1 = struct_extract %0 : $StructWithOwner, #StructWithOwner.owner
|
|
debug_value %1 : $Klass, let, name "y"
|
|
strong_retain %1 : $Klass // expected-remark {{retain of type 'Klass'}}
|
|
// expected-note @-4 {{of 'x.owner'}}
|
|
// expected-note @-3 {{of 'y'}}
|
|
return %1 : $Klass
|
|
}
|
|
|
|
// In this case, we emit the remark for x since its operand %2 is rc-identical
|
|
// to %0 the value we found while traversing our access path.
|
|
sil @rcidentity_based_use : $@convention(thin) (@guaranteed StructWithOwner, TrivialState) -> @owned Klass {
|
|
bb0(%0 : $StructWithOwner, %1 : $TrivialState):
|
|
%2 = struct $StructWithOwnerAndState(%0 : $StructWithOwner, %1 : $TrivialState)
|
|
debug_value %2 : $StructWithOwnerAndState, let, name "x"
|
|
%3 = struct_extract %0 : $StructWithOwner, #StructWithOwner.owner
|
|
strong_retain %3 : $Klass // expected-remark {{retain of type 'Klass'}}
|
|
// expected-note @-3 {{of 'x'}}
|
|
return %3 : $Klass
|
|
}
|
|
|
|
// Please keep these next to this test to make the note on the decl not far from its check.
|
|
var swiftEmptyArrayStorage: _SwiftEmptyArrayStorage
|
|
sil_global hidden @$s20opt_remark_generator22swiftEmptyArrayStorageAA06_SwiftefG0Vvp : $_SwiftEmptyArrayStorage
|
|
|
|
sil @retainOnEmptyArrayStorage : $@convention(thin) () -> @owned EmptyArrayStorage {
|
|
bb0:
|
|
%0 = global_addr @$s20opt_remark_generator22swiftEmptyArrayStorageAA06_SwiftefG0Vvp : $*_SwiftEmptyArrayStorage
|
|
%1 = address_to_pointer %0 : $*_SwiftEmptyArrayStorage to $Builtin.RawPointer
|
|
%2 = raw_pointer_to_ref %1 : $Builtin.RawPointer to $EmptyArrayStorage
|
|
strong_retain %2 : $EmptyArrayStorage // expected-remark {{retain of type 'EmptyArrayStorage'}}
|
|
// expected-note @-9 {{of 'swiftEmptyArrayStorage'}}
|
|
return %2 : $EmptyArrayStorage
|
|
}
|