File: concurrentclosure_capture_verify_raw.sil

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 (128 lines) | stat: -rw-r--r-- 8,200 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// RUN: %target-sil-opt  %s

// REQUIRES: concurrency

// This test ensures that the SILVerifier does not enforce that concurrent
// functions must have non-box parameters in raw SIL.

sil_stage raw

import Builtin

func f(_: @escaping @Sendable () -> ())

@_hasMissingDesignatedInitializers
class F {
  func useConcurrent(_: @escaping @Sendable () -> ())
  init()
}

enum FakeOptional<T> {
case none
case some(T)
}

struct Int {
  var _value: Builtin.Int64
}

class Klass {}

////////////////////
// Loadable Type  //
////////////////////

sil @$s37concurrentfunction_capturediagnostics1fyyyyJcF : $@convention(thin) (@guaranteed @Sendable @callee_guaranteed () -> ()) -> ()
sil @$sSi22_builtinIntegerLiteralSiBI_tcfC : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int // user: %5
sil @$s37concurrentfunction_capturediagnostics20testCaseTrivialValueyyFyyJcfU_ : $@convention(thin) @Sendable (@guaranteed { var Int }) -> () // user: %10

// testCaseTrivialValue()
sil hidden [ossa] @$s37concurrentfunction_capturediagnostics20testCaseTrivialValueyyF : $@convention(thin) () -> () {
bb0:
  %0 = alloc_box ${ var Int }, var, name "i"      // users: %34, %8, %1
  %1 = project_box %0 : ${ var Int }, 0           // users: %30, %26, %18, %9, %6
  %2 = integer_literal $Builtin.IntLiteral, 17    // user: %5
  %3 = metatype $@thin Int.Type                   // user: %5
  // function_ref Int.init(_builtinIntegerLiteral:)
  %4 = function_ref @$sSi22_builtinIntegerLiteralSiBI_tcfC : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int // user: %5
  %5 = apply %4(%2, %3) : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int // user: %6
  store %5 to [trivial] %1 : $*Int                // id: %6
  // function_ref closure #1 in testCaseTrivialValue()
  %7 = function_ref @$s37concurrentfunction_capturediagnostics20testCaseTrivialValueyyFyyJcfU_ : $@convention(thin) @Sendable (@guaranteed { var Int }) -> () // user: %10
  %8 = copy_value %0 : ${ var Int }               // user: %10
  mark_function_escape %1 : $*Int                 // id: %9
  %10 = partial_apply [callee_guaranteed] %7(%8) : $@convention(thin) @Sendable (@guaranteed { var Int }) -> () // users: %13, %12
  // function_ref f(_:)
  %11 = function_ref @$s37concurrentfunction_capturediagnostics1fyyyyJcF : $@convention(thin) (@guaranteed @Sendable @callee_guaranteed () -> ()) -> () // user: %12
  %12 = apply %11(%10) : $@convention(thin) (@guaranteed @Sendable @callee_guaranteed () -> ()) -> ()
  destroy_value %10 : $@Sendable @callee_guaranteed () -> () // id: %13
  destroy_value %0 : ${ var Int }
  %35 = tuple ()                                  // user: %36
  return %35 : $()                                // id: %36
} // end sil function '$s37concurrentfunction_capturediagnostics20testCaseTrivialValueyyF'


/////////////////////////////////////////
// Address Only Type Success (For Now) //
/////////////////////////////////////////

protocol MyProt {
  var i: Int { get set }
  var k: FakeOptional<Klass> { get set }
}

sil @$s37concurrentfunction_capturediagnostics1FCACycfC : $@convention(method) (@thick F.Type) -> @owned F // user: %5
sil @$s37concurrentfunction_capturediagnostics20testCaseAddressOnly21iyx_tAA6MyProtRzlFyyJcfU_ : $@convention(thin) @Sendable <τ_0_0 where τ_0_0 : MyProt> (@guaranteed <τ_0_0 where τ_0_0 : MyProt> { var τ_0_0 } <τ_0_0>) -> () // user: %15
sil @$s37concurrentfunction_capturediagnostics1FC13useConcurrentyyyyJcF : $@convention(method) (@guaranteed @Sendable @callee_guaranteed () -> (), @guaranteed F) -> () // user: %19
sil @$s37concurrentfunction_capturediagnostics17inoutUserOptKlassyyAA0F0CSgzF : $@convention(thin) (@inout FakeOptional<Klass>) -> () // user: %29
sil @$s37concurrentfunction_capturediagnostics1FCfD : $@convention(method) (@owned F) -> ()

// This is address only so we shouldn't crash.
sil hidden [ossa] @$s37concurrentfunction_capturediagnostics20testCaseAddressOnly21iyx_tAA6MyProtRzlF : $@convention(thin) <T where T : MyProt> (@in_guaranteed T) -> () {
bb0(%0 : $*T):
  debug_value %0 : $*T, let, name "i", argno 1, expr op_deref // id: %1
  %2 = alloc_stack $F, var, name "f2"             // users: %34, %33, %7
  %3 = metatype $@thick F.Type                    // user: %5
  // function_ref F.__allocating_init()
  %4 = function_ref @$s37concurrentfunction_capturediagnostics1FCACycfC : $@convention(method) (@thick F.Type) -> @owned F // user: %5
  %5 = apply %4(%3) : $@convention(method) (@thick F.Type) -> @owned F // users: %6, %7
  %6 = copy_value %5 : $F                         // users: %11, %12
  store %5 to [init] %2 : $*F                     // id: %7
  %8 = alloc_box $<τ_0_0 where τ_0_0 : MyProt> { var τ_0_0 } <T>, var, name "i2" // users: %32, %14, %9
  %9 = project_box %8 : $<τ_0_0 where τ_0_0 : MyProt> { var τ_0_0 } <T>, 0 // users: %24, %10
  copy_addr %0 to [init] %9 : $*T       // id: %10
  %11 = copy_value %6 : $F                        // users: %23, %18
  destroy_value %6 : $F                           // id: %12
  // function_ref closure #1 in testCaseAddressOnly2<A>(i:)
  %13 = function_ref @$s37concurrentfunction_capturediagnostics20testCaseAddressOnly21iyx_tAA6MyProtRzlFyyJcfU_ : $@convention(thin) @Sendable <τ_0_0 where τ_0_0 : MyProt> (@guaranteed <τ_0_0 where τ_0_0 : MyProt> { var τ_0_0 } <τ_0_0>) -> () // user: %15
  %14 = copy_value %8 : $<τ_0_0 where τ_0_0 : MyProt> { var τ_0_0 } <T> // user: %15
  %15 = partial_apply [callee_guaranteed] %13<T>(%14) : $@convention(thin) @Sendable <τ_0_0 where τ_0_0 : MyProt> (@guaranteed <τ_0_0 where τ_0_0 : MyProt> { var τ_0_0 } <τ_0_0>) -> () // users: %17, %22
  // function_ref F.useConcurrent(_:)
  %16 = function_ref @$s37concurrentfunction_capturediagnostics1FC13useConcurrentyyyyJcF : $@convention(method) (@guaranteed @Sendable @callee_guaranteed () -> (), @guaranteed F) -> () // user: %19
  %17 = begin_borrow %15 : $@Sendable @callee_guaranteed () -> () // users: %20, %19
  %18 = begin_borrow %11 : $F                     // users: %21, %19
  %19 = apply %16(%17, %18) : $@convention(method) (@guaranteed @Sendable @callee_guaranteed () -> (), @guaranteed F) -> ()
  end_borrow %17 : $@Sendable @callee_guaranteed () -> () // id: %20
  end_borrow %18 : $F                             // id: %21
  destroy_value %15 : $@Sendable @callee_guaranteed () -> () // id: %22
  destroy_value %11 : $F                          // id: %23
  %24 = begin_access [modify] [dynamic] %9 : $*T  // users: %31, %26
  %25 = witness_method $T, #MyProt.k!modify : <Self where Self : MyProt> (inout Self) -> () -> () : $@yield_once @convention(witness_method: MyProt) <τ_0_0 where τ_0_0 : MyProt> (@inout τ_0_0) -> @yields @inout FakeOptional<Klass> // user: %26
  (%26, %27) = begin_apply %25<T>(%24) : $@yield_once @convention(witness_method: MyProt) <τ_0_0 where τ_0_0 : MyProt> (@inout τ_0_0) -> @yields @inout FakeOptional<Klass> // users: %29, %30
  // function_ref inoutUserOptKlass(_:)
  %28 = function_ref @$s37concurrentfunction_capturediagnostics17inoutUserOptKlassyyAA0F0CSgzF : $@convention(thin) (@inout FakeOptional<Klass>) -> () // user: %29
  %29 = apply %28(%26) : $@convention(thin) (@inout FakeOptional<Klass>) -> ()
  end_apply %27                                   // id: %30
  end_access %24 : $*T                            // id: %31
  destroy_value %8 : $<τ_0_0 where τ_0_0 : MyProt> { var τ_0_0 } <T> // id: %32
  destroy_addr %2 : $*F                           // id: %33
  dealloc_stack %2 : $*F                          // id: %34
  %35 = tuple ()                                  // user: %36
  return %35 : $()                                // id: %36
} // end sil function '$s37concurrentfunction_capturediagnostics20testCaseAddressOnly21iyx_tAA6MyProtRzlF'

sil_vtable [serialized] F {
  #F.useConcurrent: (F) -> (@escaping @Sendable () -> ()) -> () : @$s37concurrentfunction_capturediagnostics1FC13useConcurrentyyyyJcF	// F.useConcurrent(_:)
  #F.init!allocator: (F.Type) -> () -> F : @$s37concurrentfunction_capturediagnostics1FCACycfC	// F.__allocating_init()
  #F.deinit!deallocator: @$s37concurrentfunction_capturediagnostics1FCfD	// F.__deallocating_deinit
}