File: moveonly_library_evolution.swift

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (106 lines) | stat: -rw-r--r-- 4,787 bytes parent folder | download
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// RUN: %target-swift-emit-silgen -enable-experimental-feature NoImplicitCopy -enable-library-evolution %s | %FileCheck %s
// RUN: %target-swift-emit-sil -O -sil-verify-all -enable-experimental-feature NoImplicitCopy -enable-library-evolution %s

////////////////////////
// MARK: Declarations //
////////////////////////

public struct EmptyStruct : ~Copyable {}
public struct NonEmptyStruct : ~Copyable {
    var e = EmptyStruct()
}
public class CopyableKlass {
    var s = NonEmptyStruct()

    let letStruct = NonEmptyStruct()
}

public func borrowVal(_ x: borrowing EmptyStruct) {}

//////////////////////
// MARK: DeinitTest //
//////////////////////

// CHECK-LABEL: sil [ossa] @$s26moveonly_library_evolution10DeinitTestVfD : $@convention(method) (@in DeinitTest) -> () {
// CHECK: bb0([[ARG:%.*]] : $*DeinitTest):
// CHECK:   [[TMP:%[^,]+]] = alloc_stack
// CHECK:   [[MUNV:%[^,]+]] = mark_unresolved_non_copyable_value [consumable_and_assignable] [[TMP]]
// CHECK:   copy_addr [take] [[ARG]] to [init] [[MUNV]]
// CHECK:   drop_deinit [[MUNV]]
// CHECK: } // end sil function '$s26moveonly_library_evolution10DeinitTestVfD'
public struct DeinitTest : ~Copyable {
    deinit {
    }
}

//////////////////////////////////////////
// MARK: Caller Argument Spilling Tests //
//////////////////////////////////////////

// CHECK-LABEL: sil [ossa] @$s26moveonly_library_evolution29callerArgumentSpillingTestArgyyAA13CopyableKlassCF : $@convention(thin) (@guaranteed CopyableKlass) -> () {
// CHECK: bb0([[ARG:%.*]] : @guaranteed $CopyableKlass):
// CHECK:    [[ADDR:%.*]] = ref_element_addr [[ARG]]
// CHECK:    [[MARKED_ADDR:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[ADDR]]
// CHECK:    [[GEP:%.*]] = struct_element_addr [[MARKED_ADDR]]
// CHECK:    apply {{%.*}}([[GEP]]) : $@convention(thin) (@in_guaranteed EmptyStruct) -> ()
// CHECK: } // end sil function '$s26moveonly_library_evolution29callerArgumentSpillingTestArgyyAA13CopyableKlassCF'
public func callerArgumentSpillingTestArg(_ x: CopyableKlass) {
    borrowVal(x.letStruct.e)
}

/////////////////////////////////////
// MARK: UsableFromInline in Class //
/////////////////////////////////////

public class CopyableKlass2 {
    public init() {}
}

@frozen
public struct E : ~Copyable {
    var x = CopyableKlass2()
}

public class UsableFromInlineTestKlass {
    // Read accessor
    //
    // CHECK-LABEL: sil [ossa] @$s26moveonly_library_evolution25UsableFromInlineTestKlassC1eAA1EVvr : $@yield_once @convention(method) (@guaranteed UsableFromInlineTestKlass) -> @yields @guaranteed E {
    // CHECK: bb0([[ARG:%.*]] : @guaranteed
    // CHECK:   [[FIELD:%.*]] = ref_element_addr [[ARG]]
    // CHECK:   [[ACCESS:%.*]] = begin_access [read] [dynamic] [[FIELD]]
    // CHECK:   [[MARK:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[ACCESS]]
    // CHECK:   [[LOAD:%.*]] = load [copy] [[MARK]]
    // CHECK:   yield [[LOAD]]
    // CHECK: } // end sil function '$s26moveonly_library_evolution25UsableFromInlineTestKlassC1eAA1EVvr'

    // Setter
    // CHECK-LABEL: sil [ossa] @$s26moveonly_library_evolution25UsableFromInlineTestKlassC1eAA1EVvs : $@convention(method) (@owned E, @guaranteed UsableFromInlineTestKlass) -> () {
    // CHECK: bb0([[NEW_VALUE:%.*]] : @owned $E, [[SELF:%.*]] : @guaranteed
    // CHECK:  [[VALUE:%.*]] = alloc_box ${ let E }
    // CHECK:  [[PROJECT:%.*]] = project_box [[VALUE]]
    // CHECK:  store [[NEW_VALUE]] to [init] [[PROJECT]]
    // CHECK:  [[MARK:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[PROJECT]]
    // CHECK:  [[LOAD:%.*]] = load [copy] [[MARK]]
    // CHECK:  [[REF:%.*]] = ref_element_addr [[SELF]]
    // CHECK:  [[ACCESS:%.*]] = begin_access [modify] [dynamic] [[REF]]
    // CHECK:  [[MARK:%.*]] = mark_unresolved_non_copyable_value [assignable_but_not_consumable] [[ACCESS]]
    // CHECK:  assign [[LOAD]] to [[MARK]]
    // CHECK: } // end sil function '$s26moveonly_library_evolution25UsableFromInlineTestKlassC1eAA1EVvs'

    // Modify
    // CHECK-LABEL: sil [ossa] @$s26moveonly_library_evolution25UsableFromInlineTestKlassC1eAA1EVvM : $@yield_once @convention(method) (@guaranteed UsableFromInlineTestKlass) -> @yields @inout E {
    // CHECK: bb0([[ARG:%.*]] : @guaranteed
    // CHECK:   [[FIELD:%.*]] = ref_element_addr [[ARG]]
    // CHECK:   [[ACCESS:%.*]] = begin_access [modify] [dynamic] [[FIELD]]
    // CHECK:   [[MARK:%.*]] = mark_unresolved_non_copyable_value [assignable_but_not_consumable] [[ACCESS]]
    // CHECK:   yield [[MARK]]
    // CHECK: } // end sil function '$s26moveonly_library_evolution25UsableFromInlineTestKlassC1eAA1EVvM'
    @usableFromInline
    var e = E()
}


func useUsableFromInlineTestKlass() {
    let k = UsableFromInlineTestKlass()
    k.e = E()
}