call.carbon 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/function/generic/no_prelude/call.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/generic/no_prelude/call.carbon
  10. // --- explicit.carbon
  11. library "[[@TEST_NAME]]";
  12. fn Function(T:! type, x: T) -> T {
  13. return x;
  14. }
  15. fn CallGeneric(T:! type, x: T) -> T {
  16. return Function(T, x);
  17. }
  18. fn CallGenericPtr(T:! type, x: T*) -> T* {
  19. return Function(T*, x);
  20. }
  21. class C {}
  22. fn CallSpecific(x: C) -> C {
  23. return Function(C, x);
  24. }
  25. // --- deduced.carbon
  26. library "[[@TEST_NAME]]";
  27. fn Function[T:! type](x: T) -> T {
  28. return x;
  29. }
  30. fn CallGeneric(T:! type, x: T) -> T {
  31. return Function(x);
  32. }
  33. fn CallGenericPtr(T:! type, x: T*) -> T* {
  34. return Function(x);
  35. }
  36. class C {}
  37. fn CallSpecific(x: C) -> C {
  38. return Function(x);
  39. }
  40. // CHECK:STDOUT: --- explicit.carbon
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: constants {
  43. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  44. // CHECK:STDOUT: %Function.type: type = fn_type @Function [template]
  45. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  46. // CHECK:STDOUT: %Function: %Function.type = struct_value () [template]
  47. // CHECK:STDOUT: %CallGeneric.type: type = fn_type @CallGeneric [template]
  48. // CHECK:STDOUT: %CallGeneric: %CallGeneric.type = struct_value () [template]
  49. // CHECK:STDOUT: %.2: type = ptr_type %T [symbolic]
  50. // CHECK:STDOUT: %CallGenericPtr.type: type = fn_type @CallGenericPtr [template]
  51. // CHECK:STDOUT: %CallGenericPtr: %CallGenericPtr.type = struct_value () [template]
  52. // CHECK:STDOUT: %C: type = class_type @C [template]
  53. // CHECK:STDOUT: %.3: type = struct_type {} [template]
  54. // CHECK:STDOUT: %.4: <witness> = complete_type_witness %.3 [template]
  55. // CHECK:STDOUT: %CallSpecific.type: type = fn_type @CallSpecific [template]
  56. // CHECK:STDOUT: %CallSpecific: %CallSpecific.type = struct_value () [template]
  57. // CHECK:STDOUT: %.5: type = ptr_type %.3 [template]
  58. // CHECK:STDOUT: }
  59. // CHECK:STDOUT:
  60. // CHECK:STDOUT: file {
  61. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  62. // CHECK:STDOUT: .Function = %Function.decl
  63. // CHECK:STDOUT: .CallGeneric = %CallGeneric.decl
  64. // CHECK:STDOUT: .CallGenericPtr = %CallGenericPtr.decl
  65. // CHECK:STDOUT: .C = %C.decl
  66. // CHECK:STDOUT: .CallSpecific = %CallSpecific.decl
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT: %Function.decl: %Function.type = fn_decl @Function [template = constants.%Function] {
  69. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0
  70. // CHECK:STDOUT: %x.patt: @Function.%T.1 (%T) = binding_pattern x
  71. // CHECK:STDOUT: } {
  72. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  73. // CHECK:STDOUT: %T.loc4: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.1 (constants.%T)]
  74. // CHECK:STDOUT: %T.ref.loc4_26: type = name_ref T, %T.loc4 [symbolic = %T.1 (constants.%T)]
  75. // CHECK:STDOUT: %x.param: @Function.%T.1 (%T) = param x, runtime_param0
  76. // CHECK:STDOUT: %x: @Function.%T.1 (%T) = bind_name x, %x.param
  77. // CHECK:STDOUT: %T.ref.loc4_32: type = name_ref T, %T.loc4 [symbolic = %T.1 (constants.%T)]
  78. // CHECK:STDOUT: %return: ref @Function.%T.1 (%T) = var <return slot>
  79. // CHECK:STDOUT: }
  80. // CHECK:STDOUT: %CallGeneric.decl: %CallGeneric.type = fn_decl @CallGeneric [template = constants.%CallGeneric] {
  81. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0
  82. // CHECK:STDOUT: %x.patt: @CallGeneric.%T.1 (%T) = binding_pattern x
  83. // CHECK:STDOUT: } {
  84. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  85. // CHECK:STDOUT: %T.loc8: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.1 (constants.%T)]
  86. // CHECK:STDOUT: %T.ref.loc8_29: type = name_ref T, %T.loc8 [symbolic = %T.1 (constants.%T)]
  87. // CHECK:STDOUT: %x.param: @CallGeneric.%T.1 (%T) = param x, runtime_param0
  88. // CHECK:STDOUT: %x: @CallGeneric.%T.1 (%T) = bind_name x, %x.param
  89. // CHECK:STDOUT: %T.ref.loc8_35: type = name_ref T, %T.loc8 [symbolic = %T.1 (constants.%T)]
  90. // CHECK:STDOUT: %return: ref @CallGeneric.%T.1 (%T) = var <return slot>
  91. // CHECK:STDOUT: }
  92. // CHECK:STDOUT: %CallGenericPtr.decl: %CallGenericPtr.type = fn_decl @CallGenericPtr [template = constants.%CallGenericPtr] {
  93. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0
  94. // CHECK:STDOUT: %x.patt: @CallGenericPtr.%.1 (%.2) = binding_pattern x
  95. // CHECK:STDOUT: } {
  96. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  97. // CHECK:STDOUT: %T.loc12: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.1 (constants.%T)]
  98. // CHECK:STDOUT: %T.ref.loc12_32: type = name_ref T, %T.loc12 [symbolic = %T.1 (constants.%T)]
  99. // CHECK:STDOUT: %.loc12_33: type = ptr_type %T [symbolic = %.1 (constants.%.2)]
  100. // CHECK:STDOUT: %x.param: @CallGenericPtr.%.1 (%.2) = param x, runtime_param0
  101. // CHECK:STDOUT: %x: @CallGenericPtr.%.1 (%.2) = bind_name x, %x.param
  102. // CHECK:STDOUT: %T.ref.loc12_39: type = name_ref T, %T.loc12 [symbolic = %T.1 (constants.%T)]
  103. // CHECK:STDOUT: %.loc12_40: type = ptr_type %T [symbolic = %.1 (constants.%.2)]
  104. // CHECK:STDOUT: %return: ref @CallGenericPtr.%.1 (%.2) = var <return slot>
  105. // CHECK:STDOUT: }
  106. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  107. // CHECK:STDOUT: %CallSpecific.decl: %CallSpecific.type = fn_decl @CallSpecific [template = constants.%CallSpecific] {
  108. // CHECK:STDOUT: %x.patt: %C = binding_pattern x
  109. // CHECK:STDOUT: } {
  110. // CHECK:STDOUT: %C.ref.loc18_20: type = name_ref C, file.%C.decl [template = constants.%C]
  111. // CHECK:STDOUT: %x.param: %C = param x, runtime_param0
  112. // CHECK:STDOUT: %x: %C = bind_name x, %x.param
  113. // CHECK:STDOUT: %C.ref.loc18_26: type = name_ref C, file.%C.decl [template = constants.%C]
  114. // CHECK:STDOUT: %return: ref %C = var <return slot>
  115. // CHECK:STDOUT: }
  116. // CHECK:STDOUT: }
  117. // CHECK:STDOUT:
  118. // CHECK:STDOUT: class @C {
  119. // CHECK:STDOUT: %.loc16: <witness> = complete_type_witness %.3 [template = constants.%.4]
  120. // CHECK:STDOUT:
  121. // CHECK:STDOUT: !members:
  122. // CHECK:STDOUT: .Self = constants.%C
  123. // CHECK:STDOUT: }
  124. // CHECK:STDOUT:
  125. // CHECK:STDOUT: generic fn @Function(%T.loc4: type) {
  126. // CHECK:STDOUT: %T.1: type = bind_symbolic_name T, 0 [symbolic = %T.1 (constants.%T)]
  127. // CHECK:STDOUT:
  128. // CHECK:STDOUT: !definition:
  129. // CHECK:STDOUT:
  130. // CHECK:STDOUT: fn(%T.loc4: type, %x: @Function.%T.1 (%T)) -> @Function.%T.1 (%T) {
  131. // CHECK:STDOUT: !entry:
  132. // CHECK:STDOUT: %x.ref: @Function.%T.1 (%T) = name_ref x, %x
  133. // CHECK:STDOUT: return %x.ref
  134. // CHECK:STDOUT: }
  135. // CHECK:STDOUT: }
  136. // CHECK:STDOUT:
  137. // CHECK:STDOUT: generic fn @CallGeneric(%T.loc8: type) {
  138. // CHECK:STDOUT: %T.1: type = bind_symbolic_name T, 0 [symbolic = %T.1 (constants.%T)]
  139. // CHECK:STDOUT:
  140. // CHECK:STDOUT: !definition:
  141. // CHECK:STDOUT:
  142. // CHECK:STDOUT: fn(%T.loc8: type, %x: @CallGeneric.%T.1 (%T)) -> @CallGeneric.%T.1 (%T) {
  143. // CHECK:STDOUT: !entry:
  144. // CHECK:STDOUT: %Function.ref: %Function.type = name_ref Function, file.%Function.decl [template = constants.%Function]
  145. // CHECK:STDOUT: %T.ref.loc9: type = name_ref T, %T.loc8 [symbolic = %T.1 (constants.%T)]
  146. // CHECK:STDOUT: %x.ref: @CallGeneric.%T.1 (%T) = name_ref x, %x
  147. // CHECK:STDOUT: %Function.call: init @CallGeneric.%T.1 (%T) = call %Function.ref(%x.ref)
  148. // CHECK:STDOUT: %.loc9_24.1: @CallGeneric.%T.1 (%T) = value_of_initializer %Function.call
  149. // CHECK:STDOUT: %.loc9_24.2: @CallGeneric.%T.1 (%T) = converted %Function.call, %.loc9_24.1
  150. // CHECK:STDOUT: return %.loc9_24.2
  151. // CHECK:STDOUT: }
  152. // CHECK:STDOUT: }
  153. // CHECK:STDOUT:
  154. // CHECK:STDOUT: generic fn @CallGenericPtr(%T.loc12: type) {
  155. // CHECK:STDOUT: %T.1: type = bind_symbolic_name T, 0 [symbolic = %T.1 (constants.%T)]
  156. // CHECK:STDOUT: %.1: type = ptr_type @CallGenericPtr.%T.1 (%T) [symbolic = %.1 (constants.%.2)]
  157. // CHECK:STDOUT:
  158. // CHECK:STDOUT: !definition:
  159. // CHECK:STDOUT:
  160. // CHECK:STDOUT: fn(%T.loc12: type, %x: @CallGenericPtr.%.1 (%.2)) -> @CallGenericPtr.%.1 (%.2) {
  161. // CHECK:STDOUT: !entry:
  162. // CHECK:STDOUT: %Function.ref: %Function.type = name_ref Function, file.%Function.decl [template = constants.%Function]
  163. // CHECK:STDOUT: %T.ref.loc13: type = name_ref T, %T.loc12 [symbolic = %T.1 (constants.%T)]
  164. // CHECK:STDOUT: %.loc13_20: type = ptr_type %T [symbolic = %.1 (constants.%.2)]
  165. // CHECK:STDOUT: %x.ref: @CallGenericPtr.%.1 (%.2) = name_ref x, %x
  166. // CHECK:STDOUT: %Function.call: init @CallGenericPtr.%.1 (%.2) = call %Function.ref(%x.ref)
  167. // CHECK:STDOUT: %.loc13_25.1: @CallGenericPtr.%.1 (%.2) = value_of_initializer %Function.call
  168. // CHECK:STDOUT: %.loc13_25.2: @CallGenericPtr.%.1 (%.2) = converted %Function.call, %.loc13_25.1
  169. // CHECK:STDOUT: return %.loc13_25.2
  170. // CHECK:STDOUT: }
  171. // CHECK:STDOUT: }
  172. // CHECK:STDOUT:
  173. // CHECK:STDOUT: fn @CallSpecific(%x: %C) -> %return: %C {
  174. // CHECK:STDOUT: !entry:
  175. // CHECK:STDOUT: %Function.ref: %Function.type = name_ref Function, file.%Function.decl [template = constants.%Function]
  176. // CHECK:STDOUT: %C.ref.loc19: type = name_ref C, file.%C.decl [template = constants.%C]
  177. // CHECK:STDOUT: %x.ref: %C = name_ref x, %x
  178. // CHECK:STDOUT: %.loc18: ref %C = splice_block %return {}
  179. // CHECK:STDOUT: %Function.call: init %C = call %Function.ref(%x.ref) to %.loc18
  180. // CHECK:STDOUT: return %Function.call to %return
  181. // CHECK:STDOUT: }
  182. // CHECK:STDOUT:
  183. // CHECK:STDOUT: specific @Function(constants.%T) {
  184. // CHECK:STDOUT: %T.1 => constants.%T
  185. // CHECK:STDOUT: }
  186. // CHECK:STDOUT:
  187. // CHECK:STDOUT: specific @CallGeneric(constants.%T) {
  188. // CHECK:STDOUT: %T.1 => constants.%T
  189. // CHECK:STDOUT: }
  190. // CHECK:STDOUT:
  191. // CHECK:STDOUT: specific @CallGenericPtr(constants.%T) {
  192. // CHECK:STDOUT: %T.1 => constants.%T
  193. // CHECK:STDOUT: %.1 => constants.%.2
  194. // CHECK:STDOUT: }
  195. // CHECK:STDOUT:
  196. // CHECK:STDOUT: specific @Function(constants.%.2) {
  197. // CHECK:STDOUT: %T.1 => constants.%.2
  198. // CHECK:STDOUT: }
  199. // CHECK:STDOUT:
  200. // CHECK:STDOUT: specific @Function(constants.%C) {
  201. // CHECK:STDOUT: %T.1 => constants.%C
  202. // CHECK:STDOUT: }
  203. // CHECK:STDOUT:
  204. // CHECK:STDOUT: --- deduced.carbon
  205. // CHECK:STDOUT:
  206. // CHECK:STDOUT: constants {
  207. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  208. // CHECK:STDOUT: %Function.type: type = fn_type @Function [template]
  209. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  210. // CHECK:STDOUT: %Function: %Function.type = struct_value () [template]
  211. // CHECK:STDOUT: %CallGeneric.type: type = fn_type @CallGeneric [template]
  212. // CHECK:STDOUT: %CallGeneric: %CallGeneric.type = struct_value () [template]
  213. // CHECK:STDOUT: %.2: type = ptr_type %T [symbolic]
  214. // CHECK:STDOUT: %CallGenericPtr.type: type = fn_type @CallGenericPtr [template]
  215. // CHECK:STDOUT: %CallGenericPtr: %CallGenericPtr.type = struct_value () [template]
  216. // CHECK:STDOUT: %C: type = class_type @C [template]
  217. // CHECK:STDOUT: %.3: type = struct_type {} [template]
  218. // CHECK:STDOUT: %.4: <witness> = complete_type_witness %.3 [template]
  219. // CHECK:STDOUT: %CallSpecific.type: type = fn_type @CallSpecific [template]
  220. // CHECK:STDOUT: %CallSpecific: %CallSpecific.type = struct_value () [template]
  221. // CHECK:STDOUT: %.5: type = ptr_type %.3 [template]
  222. // CHECK:STDOUT: }
  223. // CHECK:STDOUT:
  224. // CHECK:STDOUT: file {
  225. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  226. // CHECK:STDOUT: .Function = %Function.decl
  227. // CHECK:STDOUT: .CallGeneric = %CallGeneric.decl
  228. // CHECK:STDOUT: .CallGenericPtr = %CallGenericPtr.decl
  229. // CHECK:STDOUT: .C = %C.decl
  230. // CHECK:STDOUT: .CallSpecific = %CallSpecific.decl
  231. // CHECK:STDOUT: }
  232. // CHECK:STDOUT: %Function.decl: %Function.type = fn_decl @Function [template = constants.%Function] {
  233. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0
  234. // CHECK:STDOUT: %x.patt: @Function.%T.1 (%T) = binding_pattern x
  235. // CHECK:STDOUT: } {
  236. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  237. // CHECK:STDOUT: %T.loc4: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.1 (constants.%T)]
  238. // CHECK:STDOUT: %T.ref.loc4_26: type = name_ref T, %T.loc4 [symbolic = %T.1 (constants.%T)]
  239. // CHECK:STDOUT: %x.param: @Function.%T.1 (%T) = param x, runtime_param0
  240. // CHECK:STDOUT: %x: @Function.%T.1 (%T) = bind_name x, %x.param
  241. // CHECK:STDOUT: %T.ref.loc4_32: type = name_ref T, %T.loc4 [symbolic = %T.1 (constants.%T)]
  242. // CHECK:STDOUT: %return: ref @Function.%T.1 (%T) = var <return slot>
  243. // CHECK:STDOUT: }
  244. // CHECK:STDOUT: %CallGeneric.decl: %CallGeneric.type = fn_decl @CallGeneric [template = constants.%CallGeneric] {
  245. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0
  246. // CHECK:STDOUT: %x.patt: @CallGeneric.%T.1 (%T) = binding_pattern x
  247. // CHECK:STDOUT: } {
  248. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  249. // CHECK:STDOUT: %T.loc8: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.1 (constants.%T)]
  250. // CHECK:STDOUT: %T.ref.loc8_29: type = name_ref T, %T.loc8 [symbolic = %T.1 (constants.%T)]
  251. // CHECK:STDOUT: %x.param: @CallGeneric.%T.1 (%T) = param x, runtime_param0
  252. // CHECK:STDOUT: %x: @CallGeneric.%T.1 (%T) = bind_name x, %x.param
  253. // CHECK:STDOUT: %T.ref.loc8_35: type = name_ref T, %T.loc8 [symbolic = %T.1 (constants.%T)]
  254. // CHECK:STDOUT: %return: ref @CallGeneric.%T.1 (%T) = var <return slot>
  255. // CHECK:STDOUT: }
  256. // CHECK:STDOUT: %CallGenericPtr.decl: %CallGenericPtr.type = fn_decl @CallGenericPtr [template = constants.%CallGenericPtr] {
  257. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0
  258. // CHECK:STDOUT: %x.patt: @CallGenericPtr.%.1 (%.2) = binding_pattern x
  259. // CHECK:STDOUT: } {
  260. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  261. // CHECK:STDOUT: %T.loc12: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.1 (constants.%T)]
  262. // CHECK:STDOUT: %T.ref.loc12_32: type = name_ref T, %T.loc12 [symbolic = %T.1 (constants.%T)]
  263. // CHECK:STDOUT: %.loc12_33: type = ptr_type %T [symbolic = %.1 (constants.%.2)]
  264. // CHECK:STDOUT: %x.param: @CallGenericPtr.%.1 (%.2) = param x, runtime_param0
  265. // CHECK:STDOUT: %x: @CallGenericPtr.%.1 (%.2) = bind_name x, %x.param
  266. // CHECK:STDOUT: %T.ref.loc12_39: type = name_ref T, %T.loc12 [symbolic = %T.1 (constants.%T)]
  267. // CHECK:STDOUT: %.loc12_40: type = ptr_type %T [symbolic = %.1 (constants.%.2)]
  268. // CHECK:STDOUT: %return: ref @CallGenericPtr.%.1 (%.2) = var <return slot>
  269. // CHECK:STDOUT: }
  270. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  271. // CHECK:STDOUT: %CallSpecific.decl: %CallSpecific.type = fn_decl @CallSpecific [template = constants.%CallSpecific] {
  272. // CHECK:STDOUT: %x.patt: %C = binding_pattern x
  273. // CHECK:STDOUT: } {
  274. // CHECK:STDOUT: %C.ref.loc18_20: type = name_ref C, file.%C.decl [template = constants.%C]
  275. // CHECK:STDOUT: %x.param: %C = param x, runtime_param0
  276. // CHECK:STDOUT: %x: %C = bind_name x, %x.param
  277. // CHECK:STDOUT: %C.ref.loc18_26: type = name_ref C, file.%C.decl [template = constants.%C]
  278. // CHECK:STDOUT: %return: ref %C = var <return slot>
  279. // CHECK:STDOUT: }
  280. // CHECK:STDOUT: }
  281. // CHECK:STDOUT:
  282. // CHECK:STDOUT: class @C {
  283. // CHECK:STDOUT: %.loc16: <witness> = complete_type_witness %.3 [template = constants.%.4]
  284. // CHECK:STDOUT:
  285. // CHECK:STDOUT: !members:
  286. // CHECK:STDOUT: .Self = constants.%C
  287. // CHECK:STDOUT: }
  288. // CHECK:STDOUT:
  289. // CHECK:STDOUT: generic fn @Function(%T.loc4: type) {
  290. // CHECK:STDOUT: %T.1: type = bind_symbolic_name T, 0 [symbolic = %T.1 (constants.%T)]
  291. // CHECK:STDOUT:
  292. // CHECK:STDOUT: !definition:
  293. // CHECK:STDOUT:
  294. // CHECK:STDOUT: fn[%T.loc4: type](%x: @Function.%T.1 (%T)) -> @Function.%T.1 (%T) {
  295. // CHECK:STDOUT: !entry:
  296. // CHECK:STDOUT: %x.ref: @Function.%T.1 (%T) = name_ref x, %x
  297. // CHECK:STDOUT: return %x.ref
  298. // CHECK:STDOUT: }
  299. // CHECK:STDOUT: }
  300. // CHECK:STDOUT:
  301. // CHECK:STDOUT: generic fn @CallGeneric(%T.loc8: type) {
  302. // CHECK:STDOUT: %T.1: type = bind_symbolic_name T, 0 [symbolic = %T.1 (constants.%T)]
  303. // CHECK:STDOUT:
  304. // CHECK:STDOUT: !definition:
  305. // CHECK:STDOUT:
  306. // CHECK:STDOUT: fn(%T.loc8: type, %x: @CallGeneric.%T.1 (%T)) -> @CallGeneric.%T.1 (%T) {
  307. // CHECK:STDOUT: !entry:
  308. // CHECK:STDOUT: %Function.ref: %Function.type = name_ref Function, file.%Function.decl [template = constants.%Function]
  309. // CHECK:STDOUT: %x.ref: @CallGeneric.%T.1 (%T) = name_ref x, %x
  310. // CHECK:STDOUT: %Function.call: init @CallGeneric.%T.1 (%T) = call %Function.ref(%x.ref)
  311. // CHECK:STDOUT: %.loc9_21.1: @CallGeneric.%T.1 (%T) = value_of_initializer %Function.call
  312. // CHECK:STDOUT: %.loc9_21.2: @CallGeneric.%T.1 (%T) = converted %Function.call, %.loc9_21.1
  313. // CHECK:STDOUT: return %.loc9_21.2
  314. // CHECK:STDOUT: }
  315. // CHECK:STDOUT: }
  316. // CHECK:STDOUT:
  317. // CHECK:STDOUT: generic fn @CallGenericPtr(%T.loc12: type) {
  318. // CHECK:STDOUT: %T.1: type = bind_symbolic_name T, 0 [symbolic = %T.1 (constants.%T)]
  319. // CHECK:STDOUT: %.1: type = ptr_type @CallGenericPtr.%T.1 (%T) [symbolic = %.1 (constants.%.2)]
  320. // CHECK:STDOUT:
  321. // CHECK:STDOUT: !definition:
  322. // CHECK:STDOUT:
  323. // CHECK:STDOUT: fn(%T.loc12: type, %x: @CallGenericPtr.%.1 (%.2)) -> @CallGenericPtr.%.1 (%.2) {
  324. // CHECK:STDOUT: !entry:
  325. // CHECK:STDOUT: %Function.ref: %Function.type = name_ref Function, file.%Function.decl [template = constants.%Function]
  326. // CHECK:STDOUT: %x.ref: @CallGenericPtr.%.1 (%.2) = name_ref x, %x
  327. // CHECK:STDOUT: %Function.call: init @CallGenericPtr.%.1 (%.2) = call %Function.ref(%x.ref)
  328. // CHECK:STDOUT: %.loc13_21.1: @CallGenericPtr.%.1 (%.2) = value_of_initializer %Function.call
  329. // CHECK:STDOUT: %.loc13_21.2: @CallGenericPtr.%.1 (%.2) = converted %Function.call, %.loc13_21.1
  330. // CHECK:STDOUT: return %.loc13_21.2
  331. // CHECK:STDOUT: }
  332. // CHECK:STDOUT: }
  333. // CHECK:STDOUT:
  334. // CHECK:STDOUT: fn @CallSpecific(%x: %C) -> %return: %C {
  335. // CHECK:STDOUT: !entry:
  336. // CHECK:STDOUT: %Function.ref: %Function.type = name_ref Function, file.%Function.decl [template = constants.%Function]
  337. // CHECK:STDOUT: %x.ref: %C = name_ref x, %x
  338. // CHECK:STDOUT: %.loc18: ref %C = splice_block %return {}
  339. // CHECK:STDOUT: %Function.call: init %C = call %Function.ref(%x.ref) to %.loc18
  340. // CHECK:STDOUT: return %Function.call to %return
  341. // CHECK:STDOUT: }
  342. // CHECK:STDOUT:
  343. // CHECK:STDOUT: specific @Function(constants.%T) {
  344. // CHECK:STDOUT: %T.1 => constants.%T
  345. // CHECK:STDOUT: }
  346. // CHECK:STDOUT:
  347. // CHECK:STDOUT: specific @CallGeneric(constants.%T) {
  348. // CHECK:STDOUT: %T.1 => constants.%T
  349. // CHECK:STDOUT: }
  350. // CHECK:STDOUT:
  351. // CHECK:STDOUT: specific @CallGenericPtr(constants.%T) {
  352. // CHECK:STDOUT: %T.1 => constants.%T
  353. // CHECK:STDOUT: %.1 => constants.%.2
  354. // CHECK:STDOUT: }
  355. // CHECK:STDOUT:
  356. // CHECK:STDOUT: specific @Function(constants.%.2) {
  357. // CHECK:STDOUT: %T.1 => constants.%.2
  358. // CHECK:STDOUT: }
  359. // CHECK:STDOUT:
  360. // CHECK:STDOUT: specific @Function(constants.%C) {
  361. // CHECK:STDOUT: %T.1 => constants.%C
  362. // CHECK:STDOUT: }
  363. // CHECK:STDOUT: