Files
swift-mirror/test/SIL/moveonly_ownership.sil
Nate Chandler bf65f21cc8 [Test] Underscored is_sil_trivial.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:50:17 -07:00

166 lines
6.8 KiB
Plaintext

// RUN: %target-sil-opt -test-runner %s -o /dev/null 2>&1 | %FileCheck %s
sil_stage raw
import Builtin
import Swift
import SwiftShims
struct FakeInt {
var i: Builtin.Int32
}
struct MO_DEINIT: ~Copyable {
@_hasStorage var value: FakeInt { get set }
deinit
init(value: FakeInt)
}
struct NC_DEINIT : ~Copyable {
@_hasStorage var value: FakeInt { get set }
deinit
init(value: FakeInt)
}
struct MO: ~Copyable {
@_hasStorage var value: FakeInt { get set }
}
struct NC : ~Copyable {
@_hasStorage var value: FakeInt { get set }
}
// CHECK: begin running test 1 of 4 on motest1: is_sil_trivial with: @instruction[2]
// CHECK: %2 = struct $MO_DEINIT (%1 : $FakeInt)
// CHECK: is not trivial
// CHECK: end running test 1 of 4 on motest1: is_sil_trivial with: @instruction[2]
// CHECK: begin running test 2 of 4 on motest1: get_ownership_kind with: @instruction[2]
// CHECK: %2 = struct $MO_DEINIT (%1 : $FakeInt)
// CHECK: OwnershipKind: owned
// CHECK: end running test 2 of 4 on motest1: get_ownership_kind with: @instruction[2]
// CHECK: begin running test 3 of 4 on motest1: is_sil_trivial with: @instruction[4]
// CHECK: %4 = move_value [lexical] %2 : $MO_DEINIT
// CHECK: is not trivial
// CHECK: end running test 3 of 4 on motest1: is_sil_trivial with: @instruction[4]
// CHECK: begin running test 4 of 4 on motest1: get_ownership_kind with: @instruction[4]
// CHECK: %4 = move_value [lexical] %2 : $MO_DEINIT
// CHECK: OwnershipKind: owned
// CHECK: end running test 4 of 4 on motest1: get_ownership_kind with: @instruction[4]
sil hidden [ossa] @motest1 : $@convention(thin) () -> () {
[global: read,write,copy,destroy,allocate,deinit_barrier]
bb0:
specify_test "is_sil_trivial @instruction[2]"
specify_test "get_ownership_kind @instruction[2]"
specify_test "is_sil_trivial @instruction[4]"
specify_test "get_ownership_kind @instruction[4]"
%0 = integer_literal $Builtin.Int32, 38
%1 = struct $FakeInt (%0 : $Builtin.Int32)
%2 = struct $MO_DEINIT (%1 : $FakeInt)
debug_value %2 : $MO_DEINIT, let, name "b"
%4 = move_value [lexical] %2 : $MO_DEINIT
destroy_value %4 : $MO_DEINIT
%6 = tuple ()
return %6 : $()
}
// CHECK: begin running test 1 of 4 on motest2: is_sil_trivial with: @instruction[2]
// CHECK: %2 = struct $MO (%1 : $FakeInt)
// CHECK: is not trivial
// CHECK: end running test 1 of 4 on motest2: is_sil_trivial with: @instruction[2]
// CHECK: begin running test 2 of 4 on motest2: get_ownership_kind with: @instruction[2]
// CHECK: %2 = struct $MO (%1 : $FakeInt)
// CHECK: OwnershipKind: owned
// CHECK: end running test 2 of 4 on motest2: get_ownership_kind with: @instruction[2]
// CHECK: begin running test 3 of 4 on motest2: is_sil_trivial with: @instruction[4]
// CHECK: %4 = move_value [lexical] %2 : $MO
// CHECK: is not trivial
// CHECK: end running test 3 of 4 on motest2: is_sil_trivial with: @instruction[4]
// CHECK: begin running test 4 of 4 on motest2: get_ownership_kind with: @instruction[4]
// CHECK: %4 = move_value [lexical] %2 : $MO
// CHECK: OwnershipKind: owned
// CHECK: end running test 4 of 4 on motest2: get_ownership_kind with: @instruction[4]
sil hidden [ossa] @motest2 : $@convention(thin) () -> () {
[global: read,write,copy,destroy,allocate,deinit_barrier]
bb0:
specify_test "is_sil_trivial @instruction[2]"
specify_test "get_ownership_kind @instruction[2]"
specify_test "is_sil_trivial @instruction[4]"
specify_test "get_ownership_kind @instruction[4]"
%0 = integer_literal $Builtin.Int32, 38
%1 = struct $FakeInt (%0 : $Builtin.Int32)
%2 = struct $MO (%1 : $FakeInt)
debug_value %2 : $MO, let, name "b"
%4 = move_value [lexical] %2 : $MO
destroy_value %4 : $MO
%6 = tuple ()
return %6 : $()
}
// CHECK: begin running test 1 of 4 on nctest1: is_sil_trivial with: @instruction[2]
// CHECK: %2 = struct $NC_DEINIT (%1 : $FakeInt)
// CHECK: is not trivial
// CHECK: end running test 1 of 4 on nctest1: is_sil_trivial with: @instruction[2]
// CHECK: begin running test 2 of 4 on nctest1: get_ownership_kind with: @instruction[2]
// CHECK: %2 = struct $NC_DEINIT (%1 : $FakeInt)
// CHECK: OwnershipKind: owned
// CHECK: end running test 2 of 4 on nctest1: get_ownership_kind with: @instruction[2]
// CHECK: begin running test 3 of 4 on nctest1: is_sil_trivial with: @instruction[4]
// CHECK: %4 = move_value [lexical] %2 : $NC_DEINIT
// CHECK: is not trivial
// CHECK: end running test 3 of 4 on nctest1: is_sil_trivial with: @instruction[4]
// CHECK: begin running test 4 of 4 on nctest1: get_ownership_kind with: @instruction[4]
// CHECK: %4 = move_value [lexical] %2 : $NC_DEINIT
// CHECK: OwnershipKind: owned
// CHECK: end running test 4 of 4 on nctest1: get_ownership_kind with: @instruction[4]
sil hidden [ossa] @nctest1 : $@convention(thin) () -> () {
[global: read,write,copy,destroy,allocate,deinit_barrier]
bb0:
specify_test "is_sil_trivial @instruction[2]"
specify_test "get_ownership_kind @instruction[2]"
specify_test "is_sil_trivial @instruction[4]"
specify_test "get_ownership_kind @instruction[4]"
%0 = integer_literal $Builtin.Int32, 38
%1 = struct $FakeInt (%0 : $Builtin.Int32)
%2 = struct $NC_DEINIT (%1 : $FakeInt)
debug_value %2 : $NC_DEINIT, let, name "b"
%4 = move_value [lexical] %2 : $NC_DEINIT
destroy_value %4 : $NC_DEINIT
%6 = tuple ()
return %6 : $()
}
// CHECK: begin running test 1 of 4 on nctest2: is_sil_trivial with: @instruction[2]
// CHECK: %2 = struct $NC (%1 : $FakeInt)
// CHECK: is not trivial
// CHECK: end running test 1 of 4 on nctest2: is_sil_trivial with: @instruction[2]
// CHECK: begin running test 2 of 4 on nctest2: get_ownership_kind with: @instruction[2]
// CHECK: %2 = struct $NC (%1 : $FakeInt)
// CHECK: OwnershipKind: owned
// CHECK: end running test 2 of 4 on nctest2: get_ownership_kind with: @instruction[2]
// CHECK: begin running test 3 of 4 on nctest2: is_sil_trivial with: @instruction[4]
// CHECK: %4 = move_value [lexical] %2 : $NC
// CHECK: is not trivial
// CHECK: end running test 3 of 4 on nctest2: is_sil_trivial with: @instruction[4]
// CHECK: begin running test 4 of 4 on nctest2: get_ownership_kind with: @instruction[4]
// CHECK: %4 = move_value [lexical] %2 : $NC
// CHECK: OwnershipKind: owned
// CHECK: end running test 4 of 4 on nctest2: get_ownership_kind with: @instruction[4]
sil hidden [ossa] @nctest2 : $@convention(thin) () -> () {
[global: read,write,copy,destroy,allocate,deinit_barrier]
bb0:
specify_test "is_sil_trivial @instruction[2]"
specify_test "get_ownership_kind @instruction[2]"
specify_test "is_sil_trivial @instruction[4]"
specify_test "get_ownership_kind @instruction[4]"
%0 = integer_literal $Builtin.Int32, 38
%1 = struct $FakeInt (%0 : $Builtin.Int32)
%2 = struct $NC (%1 : $FakeInt)
debug_value %2 : $NC, let, name "b"
%4 = move_value [lexical] %2 : $NC
destroy_value %4 : $NC
%6 = tuple ()
return %6 : $()
}