File: partial_apply_run_generic_method1.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 (211 lines) | stat: -rw-r--r-- 8,276 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
// RUN: %empty-directory(%t)
// RUN: %target-build-swift-dylib(%t/%target-library-name(PrintShims)) %S/../Inputs/print-shims.swift -module-name PrintShims -emit-module -emit-module-path %t/PrintShims.swiftmodule
// RUN: %target-codesign %t/%target-library-name(PrintShims)
// RUN: %target-build-swift -g -parse-sil %s -Xllvm -sil-disable-pass=Simplification -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL
// RUN: %target-build-swift -g -parse-sil %s -Xllvm -sil-disable-pass=Simplification -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
// RUN: %target-codesign %t/main
// RUN: %target-run %t/main %t/%target-library-name(PrintShims) | %FileCheck %s

// REQUIRES: executable_test
// REQUIRES: swift_test_mode_optimize_none

sil_stage raw

import Builtin
import Swift
import SwiftShims

// CHECK-LL-LABEL: define hidden swiftcc void @call_generic_function
//       CHECK-LL:   call swiftcc void{{(.*)}} @"$sTA
sil hidden [ossa] @call_generic_function : $@convention(thin) <On, T where On : C> (@guaranteed On, @in_guaranteed T) -> @out T {
bb0(%out : $*T, %on_guaranteed : @guaranteed $On, %in : $*T):
  %on = copy_value %on_guaranteed : $On
  %c = upcast %on : $On to $C
  %method = class_method %c : $C, #C.generic_function : <T> (C) -> (T) -> T, $@convention(method) <τ_0_0> (@in_guaranteed τ_0_0, @guaranteed C) -> @out τ_0_0
  %closure = partial_apply [callee_guaranteed] %method<T>(%c) : $@convention(method) <τ_1_0> (@in_guaranteed τ_1_0, @guaranteed C) -> @out τ_1_0
  %result = apply %closure(%out, %in) : $@callee_guaranteed (@in_guaranteed T) -> @out T
  destroy_value %closure : $@callee_guaranteed (@in_guaranteed T) -> @out T
  return %result : $()
}













class C {
  @_silgen_name("generic_function")
  func generic_function<T>(_ t: T) -> T
  deinit
  init()
}

@_silgen_name("call_generic_function")
func call_generic_function<On, T>(on: On, with t: T) -> T where On : C

@main struct Main {
  static func main()
  init()
}


sil hidden [ossa] @generic_function : $@convention(method) <T> (@in_guaranteed T, @guaranteed C) -> @out T {



bb0(%0 : $*T, %1 : $*T, %2 : @guaranteed $C):
  debug_value %1 : $*T, let, name "t", argno 1 , expr op_deref
  debug_value %2 : $C, let, name "self", argno 2  
  copy_addr %1 to [init] %0 : $*T       
  %6 = tuple ()                                   
  return %6 : $()                                 
} 


sil hidden [ossa] @$s4main1CCfd : $@convention(method) (@guaranteed C) -> @owned Builtin.NativeObject {

bb0(%0 : @guaranteed $C):
  debug_value %0 : $C, let, name "self", argno 1  
  %2 = unchecked_ref_cast %0 : $C to $Builtin.NativeObject 
  %3 = unchecked_ownership_conversion %2 : $Builtin.NativeObject, @guaranteed to @owned 
  return %3 : $Builtin.NativeObject               
} 


sil hidden [ossa] @$s4main1CCfD : $@convention(method) (@owned C) -> () {

bb0(%0 : @owned $C):
  debug_value %0 : $C, let, name "self", argno 1  
  
  %2 = function_ref @$s4main1CCfd : $@convention(method) (@guaranteed C) -> @owned Builtin.NativeObject 
  %3 = begin_borrow %0 : $C                       
  %4 = apply %2(%3) : $@convention(method) (@guaranteed C) -> @owned Builtin.NativeObject 
  end_borrow %3 : $C                              
  end_lifetime %0 : $C                            
  %7 = unchecked_ref_cast %4 : $Builtin.NativeObject to $C 
  dealloc_ref %7 : $C                             
  %9 = tuple ()                                   
  return %9 : $()                                 
} 


sil hidden [exact_self_class] [ossa] @$s4main1CCACycfC : $@convention(method) (@thick C.Type) -> @owned C {

bb0(%0 : $@thick C.Type):
  %1 = alloc_ref $C                               
  
  %2 = function_ref @$s4main1CCACycfc : $@convention(method) (@owned C) -> @owned C 
  %3 = apply %2(%1) : $@convention(method) (@owned C) -> @owned C 
  return %3 : $C                                  
} 


sil hidden [ossa] @$s4main1CCACycfc : $@convention(method) (@owned C) -> @owned C {

bb0(%0 : @owned $C):
  debug_value %0 : $C, let, name "self", argno 1  
  %2 = mark_uninitialized [rootself] %0 : $C      
  %3 = copy_value %2 : $C                         
  destroy_value %2 : $C                           
  return %3 : $C                                  
} 


sil hidden [ossa] @$s4main4MainVAAyyFZ : $@convention(method) (@thin Main.Type) -> () {

bb0(%0 : $@thin Main.Type):
  debug_value %0 : $@thin Main.Type, let, name "self", argno 1 
  %2 = metatype $@thick C.Type                    
  
  %3 = function_ref @$s4main1CCACycfC : $@convention(method) (@thick C.Type) -> @owned C 
  %4 = apply %3(%2) : $@convention(method) (@thick C.Type) -> @owned C 
  debug_value %4 : $C, let, name "s"              
  %6 = integer_literal $Builtin.IntLiteral, 42    
  %7 = metatype $@thin Int.Type                   
  
  %8 = function_ref @$sSi22_builtinIntegerLiteralSiBI_tcfC : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int 
  %9 = apply %8(%6, %7) : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int 
  debug_value %9 : $Int, let, name "t"            
  %11 = alloc_stack $Int                          
  %12 = begin_borrow %4 : $C                      
  %13 = alloc_stack $Int                          
  store %9 to [trivial] %13 : $*Int               
  
  %15 = function_ref @call_generic_function : $@convention(thin) <τ_0_0, τ_0_1 where τ_0_0 : C> (@guaranteed τ_0_0, @in_guaranteed τ_0_1) -> @out τ_0_1 
  %16 = apply %15<C, Int>(%11, %12, %13) : $@convention(thin) <τ_0_0, τ_0_1 where τ_0_0 : C> (@guaranteed τ_0_0, @in_guaranteed τ_0_1) -> @out τ_0_1
  dealloc_stack %13 : $*Int                       
  end_borrow %12 : $C                             
  %19 = load [trivial] %11 : $*Int                
  debug_value %19 : $Int, let, name "out"         
  dealloc_stack %11 : $*Int                       
  %22 = alloc_stack $Int                          
  store %19 to [trivial] %22 : $*Int              
  
  %24 = function_ref @printGeneric : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> () 
  // CHECK: 42
  %25 = apply %24<Int>(%22) : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> ()
  dealloc_stack %22 : $*Int                       
  destroy_value %4 : $C                           
  %28 = tuple ()                                  
  return %28 : $()                                
} 


sil [transparent] [serialized] @$sSi22_builtinIntegerLiteralSiBI_tcfC : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int


sil public_external @printGeneric : $@convention(thin) <T> (@in_guaranteed T) -> ()


sil hidden [ossa] @$s4main4MainVACycfC : $@convention(method) (@thin Main.Type) -> Main {

bb0(%0 : $@thin Main.Type):
  %1 = alloc_box ${ var Main }, var, name "self"  
  %2 = mark_uninitialized [rootself] %1 : ${ var Main } 
  %3 = project_box %2 : ${ var Main }, 0          
  %4 = load [trivial] %3 : $*Main                 
  destroy_value %2 : ${ var Main }                
  return %4 : $Main                               
} 


sil hidden [ossa] @$s4main4MainV5$mainyyFZ : $@convention(method) (@thin Main.Type) -> () {

bb0(%0 : $@thin Main.Type):
  debug_value %0 : $@thin Main.Type, let, name "self", argno 1 
  %2 = metatype $@thin Main.Type                  
  
  %3 = function_ref @$s4main4MainVAAyyFZ : $@convention(method) (@thin Main.Type) -> () 
  %4 = apply %3(%2) : $@convention(method) (@thin Main.Type) -> ()
  %5 = tuple ()                                   
  return %5 : $()                                 
} 



sil [ossa] @main : $@convention(c) () -> Int32 {
  %2 = metatype $@thin Main.Type                  
  
  %3 = function_ref @$s4main4MainV5$mainyyFZ : $@convention(method) (@thin Main.Type) -> () 
  %4 = apply %3(%2) : $@convention(method) (@thin Main.Type) -> ()
  %5 = integer_literal $Builtin.Int32, 0          
  br bb1(%5 : $Builtin.Int32)                     


bb1(%7 : $Builtin.Int32):                         
  %8 = struct $Int32 (%7 : $Builtin.Int32)        
  return %8 : $Int32                              
} 

sil_vtable C {
  #C.generic_function: <T> (C) -> (T) -> T : @generic_function	
  #C.init!allocator: (C.Type) -> () -> C : @$s4main1CCACycfC	
  #C.deinit!deallocator: @$s4main1CCfD	
}