call.carbon 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  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: %CallSpecific.type: type = fn_type @CallSpecific [template]
  55. // CHECK:STDOUT: %CallSpecific: %CallSpecific.type = struct_value () [template]
  56. // CHECK:STDOUT: %.4: type = ptr_type %.3 [template]
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: file {
  60. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  61. // CHECK:STDOUT: .Function = %Function.decl
  62. // CHECK:STDOUT: .CallGeneric = %CallGeneric.decl
  63. // CHECK:STDOUT: .CallGenericPtr = %CallGenericPtr.decl
  64. // CHECK:STDOUT: .C = %C.decl
  65. // CHECK:STDOUT: .CallSpecific = %CallSpecific.decl
  66. // CHECK:STDOUT: }
  67. // CHECK:STDOUT: %Function.decl: %Function.type = fn_decl @Function [template = constants.%Function] {
  68. // CHECK:STDOUT: %T.loc4_13.1: type = param T, runtime_param<invalid>
  69. // CHECK:STDOUT: @Function.%T.loc4: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = @Function.%T.1 (constants.%T)]
  70. // CHECK:STDOUT: %T.ref.loc4_26: type = name_ref T, @Function.%T.loc4 [symbolic = @Function.%T.1 (constants.%T)]
  71. // CHECK:STDOUT: %x.loc4_23.1: @Function.%T.1 (%T) = param x, runtime_param0
  72. // CHECK:STDOUT: @Function.%x: @Function.%T.1 (%T) = bind_name x, %x.loc4_23.1
  73. // CHECK:STDOUT: %T.ref.loc4_32: type = name_ref T, @Function.%T.loc4 [symbolic = @Function.%T.1 (constants.%T)]
  74. // CHECK:STDOUT: @Function.%return: ref @Function.%T.1 (%T) = var <return slot>
  75. // CHECK:STDOUT: }
  76. // CHECK:STDOUT: %CallGeneric.decl: %CallGeneric.type = fn_decl @CallGeneric [template = constants.%CallGeneric] {
  77. // CHECK:STDOUT: %T.loc8_16.1: type = param T, runtime_param<invalid>
  78. // CHECK:STDOUT: @CallGeneric.%T.loc8: type = bind_symbolic_name T 0, %T.loc8_16.1 [symbolic = @CallGeneric.%T.1 (constants.%T)]
  79. // CHECK:STDOUT: %T.ref.loc8_29: type = name_ref T, @CallGeneric.%T.loc8 [symbolic = @CallGeneric.%T.1 (constants.%T)]
  80. // CHECK:STDOUT: %x.loc8_26.1: @CallGeneric.%T.1 (%T) = param x, runtime_param0
  81. // CHECK:STDOUT: @CallGeneric.%x: @CallGeneric.%T.1 (%T) = bind_name x, %x.loc8_26.1
  82. // CHECK:STDOUT: %T.ref.loc8_35: type = name_ref T, @CallGeneric.%T.loc8 [symbolic = @CallGeneric.%T.1 (constants.%T)]
  83. // CHECK:STDOUT: @CallGeneric.%return: ref @CallGeneric.%T.1 (%T) = var <return slot>
  84. // CHECK:STDOUT: }
  85. // CHECK:STDOUT: %CallGenericPtr.decl: %CallGenericPtr.type = fn_decl @CallGenericPtr [template = constants.%CallGenericPtr] {
  86. // CHECK:STDOUT: %T.loc12_19.1: type = param T, runtime_param<invalid>
  87. // CHECK:STDOUT: @CallGenericPtr.%T.loc12: type = bind_symbolic_name T 0, %T.loc12_19.1 [symbolic = @CallGenericPtr.%T.1 (constants.%T)]
  88. // CHECK:STDOUT: %T.ref.loc12_32: type = name_ref T, @CallGenericPtr.%T.loc12 [symbolic = @CallGenericPtr.%T.1 (constants.%T)]
  89. // CHECK:STDOUT: %.loc12_33: type = ptr_type %T [symbolic = @CallGenericPtr.%.1 (constants.%.2)]
  90. // CHECK:STDOUT: %x.loc12_29.1: @CallGenericPtr.%.1 (%.2) = param x, runtime_param0
  91. // CHECK:STDOUT: @CallGenericPtr.%x: @CallGenericPtr.%.1 (%.2) = bind_name x, %x.loc12_29.1
  92. // CHECK:STDOUT: %T.ref.loc12_39: type = name_ref T, @CallGenericPtr.%T.loc12 [symbolic = @CallGenericPtr.%T.1 (constants.%T)]
  93. // CHECK:STDOUT: %.loc12_40: type = ptr_type %T [symbolic = @CallGenericPtr.%.1 (constants.%.2)]
  94. // CHECK:STDOUT: @CallGenericPtr.%return: ref @CallGenericPtr.%.1 (%.2) = var <return slot>
  95. // CHECK:STDOUT: }
  96. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
  97. // CHECK:STDOUT: %CallSpecific.decl: %CallSpecific.type = fn_decl @CallSpecific [template = constants.%CallSpecific] {
  98. // CHECK:STDOUT: %C.ref.loc18_20: type = name_ref C, %C.decl [template = constants.%C]
  99. // CHECK:STDOUT: %x.loc18_17.1: %C = param x, runtime_param0
  100. // CHECK:STDOUT: @CallSpecific.%x: %C = bind_name x, %x.loc18_17.1
  101. // CHECK:STDOUT: %C.ref.loc18_26: type = name_ref C, %C.decl [template = constants.%C]
  102. // CHECK:STDOUT: @CallSpecific.%return: ref %C = var <return slot>
  103. // CHECK:STDOUT: }
  104. // CHECK:STDOUT: }
  105. // CHECK:STDOUT:
  106. // CHECK:STDOUT: class @C {
  107. // CHECK:STDOUT: !members:
  108. // CHECK:STDOUT: .Self = constants.%C
  109. // CHECK:STDOUT: }
  110. // CHECK:STDOUT:
  111. // CHECK:STDOUT: generic fn @Function(%T.loc4: type) {
  112. // CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)]
  113. // CHECK:STDOUT:
  114. // CHECK:STDOUT: !definition:
  115. // CHECK:STDOUT:
  116. // CHECK:STDOUT: fn(%T.loc4: type, %x: @Function.%T.1 (%T)) -> @Function.%T.1 (%T) {
  117. // CHECK:STDOUT: !entry:
  118. // CHECK:STDOUT: %x.ref: @Function.%T.1 (%T) = name_ref x, %x
  119. // CHECK:STDOUT: return %x.ref
  120. // CHECK:STDOUT: }
  121. // CHECK:STDOUT: }
  122. // CHECK:STDOUT:
  123. // CHECK:STDOUT: generic fn @CallGeneric(%T.loc8: type) {
  124. // CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)]
  125. // CHECK:STDOUT:
  126. // CHECK:STDOUT: !definition:
  127. // CHECK:STDOUT:
  128. // CHECK:STDOUT: fn(%T.loc8: type, %x: @CallGeneric.%T.1 (%T)) -> @CallGeneric.%T.1 (%T) {
  129. // CHECK:STDOUT: !entry:
  130. // CHECK:STDOUT: %Function.ref: %Function.type = name_ref Function, file.%Function.decl [template = constants.%Function]
  131. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc8 [symbolic = %T.1 (constants.%T)]
  132. // CHECK:STDOUT: %x.ref: @CallGeneric.%T.1 (%T) = name_ref x, %x
  133. // CHECK:STDOUT: %Function.call: init @CallGeneric.%T.1 (%T) = call %Function.ref(%x.ref)
  134. // CHECK:STDOUT: %.loc9_24.1: @CallGeneric.%T.1 (%T) = value_of_initializer %Function.call
  135. // CHECK:STDOUT: %.loc9_24.2: @CallGeneric.%T.1 (%T) = converted %Function.call, %.loc9_24.1
  136. // CHECK:STDOUT: return %.loc9_24.2
  137. // CHECK:STDOUT: }
  138. // CHECK:STDOUT: }
  139. // CHECK:STDOUT:
  140. // CHECK:STDOUT: generic fn @CallGenericPtr(%T.loc12: type) {
  141. // CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)]
  142. // CHECK:STDOUT: %.1: type = ptr_type @CallGenericPtr.%T.1 (%T) [symbolic = %.1 (constants.%.2)]
  143. // CHECK:STDOUT:
  144. // CHECK:STDOUT: !definition:
  145. // CHECK:STDOUT:
  146. // CHECK:STDOUT: fn(%T.loc12: type, %x: @CallGenericPtr.%.1 (%.2)) -> @CallGenericPtr.%.1 (%.2) {
  147. // CHECK:STDOUT: !entry:
  148. // CHECK:STDOUT: %Function.ref: %Function.type = name_ref Function, file.%Function.decl [template = constants.%Function]
  149. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc12 [symbolic = %T.1 (constants.%T)]
  150. // CHECK:STDOUT: %.loc13_20: type = ptr_type %T [symbolic = %.1 (constants.%.2)]
  151. // CHECK:STDOUT: %x.ref: @CallGenericPtr.%.1 (%.2) = name_ref x, %x
  152. // CHECK:STDOUT: %Function.call: init @CallGenericPtr.%.1 (%.2) = call %Function.ref(%x.ref)
  153. // CHECK:STDOUT: %.loc13_25.1: @CallGenericPtr.%.1 (%.2) = value_of_initializer %Function.call
  154. // CHECK:STDOUT: %.loc13_25.2: @CallGenericPtr.%.1 (%.2) = converted %Function.call, %.loc13_25.1
  155. // CHECK:STDOUT: return %.loc13_25.2
  156. // CHECK:STDOUT: }
  157. // CHECK:STDOUT: }
  158. // CHECK:STDOUT:
  159. // CHECK:STDOUT: fn @CallSpecific(%x: %C) -> %return: %C {
  160. // CHECK:STDOUT: !entry:
  161. // CHECK:STDOUT: %Function.ref: %Function.type = name_ref Function, file.%Function.decl [template = constants.%Function]
  162. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  163. // CHECK:STDOUT: %x.ref: %C = name_ref x, %x
  164. // CHECK:STDOUT: %.loc18: ref %C = splice_block %return {}
  165. // CHECK:STDOUT: %Function.call: init %C = call %Function.ref(%x.ref) to %.loc18
  166. // CHECK:STDOUT: return %Function.call to %return
  167. // CHECK:STDOUT: }
  168. // CHECK:STDOUT:
  169. // CHECK:STDOUT: specific @Function(constants.%T) {
  170. // CHECK:STDOUT: %T.1 => constants.%T
  171. // CHECK:STDOUT: }
  172. // CHECK:STDOUT:
  173. // CHECK:STDOUT: specific @CallGeneric(constants.%T) {
  174. // CHECK:STDOUT: %T.1 => constants.%T
  175. // CHECK:STDOUT: }
  176. // CHECK:STDOUT:
  177. // CHECK:STDOUT: specific @CallGenericPtr(constants.%T) {
  178. // CHECK:STDOUT: %T.1 => constants.%T
  179. // CHECK:STDOUT: %.1 => constants.%.2
  180. // CHECK:STDOUT: }
  181. // CHECK:STDOUT:
  182. // CHECK:STDOUT: specific @Function(constants.%.2) {
  183. // CHECK:STDOUT: %T.1 => constants.%.2
  184. // CHECK:STDOUT: }
  185. // CHECK:STDOUT:
  186. // CHECK:STDOUT: specific @Function(constants.%C) {
  187. // CHECK:STDOUT: %T.1 => constants.%C
  188. // CHECK:STDOUT: }
  189. // CHECK:STDOUT:
  190. // CHECK:STDOUT: --- deduced.carbon
  191. // CHECK:STDOUT:
  192. // CHECK:STDOUT: constants {
  193. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic]
  194. // CHECK:STDOUT: %Function.type: type = fn_type @Function [template]
  195. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  196. // CHECK:STDOUT: %Function: %Function.type = struct_value () [template]
  197. // CHECK:STDOUT: %CallGeneric.type: type = fn_type @CallGeneric [template]
  198. // CHECK:STDOUT: %CallGeneric: %CallGeneric.type = struct_value () [template]
  199. // CHECK:STDOUT: %.2: type = ptr_type %T [symbolic]
  200. // CHECK:STDOUT: %CallGenericPtr.type: type = fn_type @CallGenericPtr [template]
  201. // CHECK:STDOUT: %CallGenericPtr: %CallGenericPtr.type = struct_value () [template]
  202. // CHECK:STDOUT: %C: type = class_type @C [template]
  203. // CHECK:STDOUT: %.3: type = struct_type {} [template]
  204. // CHECK:STDOUT: %CallSpecific.type: type = fn_type @CallSpecific [template]
  205. // CHECK:STDOUT: %CallSpecific: %CallSpecific.type = struct_value () [template]
  206. // CHECK:STDOUT: %.4: type = ptr_type %.3 [template]
  207. // CHECK:STDOUT: }
  208. // CHECK:STDOUT:
  209. // CHECK:STDOUT: file {
  210. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  211. // CHECK:STDOUT: .Function = %Function.decl
  212. // CHECK:STDOUT: .CallGeneric = %CallGeneric.decl
  213. // CHECK:STDOUT: .CallGenericPtr = %CallGenericPtr.decl
  214. // CHECK:STDOUT: .C = %C.decl
  215. // CHECK:STDOUT: .CallSpecific = %CallSpecific.decl
  216. // CHECK:STDOUT: }
  217. // CHECK:STDOUT: %Function.decl: %Function.type = fn_decl @Function [template = constants.%Function] {
  218. // CHECK:STDOUT: %T.loc4_13.1: type = param T, runtime_param<invalid>
  219. // CHECK:STDOUT: @Function.%T.loc4: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = @Function.%T.1 (constants.%T)]
  220. // CHECK:STDOUT: %T.ref.loc4_26: type = name_ref T, @Function.%T.loc4 [symbolic = @Function.%T.1 (constants.%T)]
  221. // CHECK:STDOUT: %x.loc4_23.1: @Function.%T.1 (%T) = param x, runtime_param0
  222. // CHECK:STDOUT: @Function.%x: @Function.%T.1 (%T) = bind_name x, %x.loc4_23.1
  223. // CHECK:STDOUT: %T.ref.loc4_32: type = name_ref T, @Function.%T.loc4 [symbolic = @Function.%T.1 (constants.%T)]
  224. // CHECK:STDOUT: @Function.%return: ref @Function.%T.1 (%T) = var <return slot>
  225. // CHECK:STDOUT: }
  226. // CHECK:STDOUT: %CallGeneric.decl: %CallGeneric.type = fn_decl @CallGeneric [template = constants.%CallGeneric] {
  227. // CHECK:STDOUT: %T.loc8_16.1: type = param T, runtime_param<invalid>
  228. // CHECK:STDOUT: @CallGeneric.%T.loc8: type = bind_symbolic_name T 0, %T.loc8_16.1 [symbolic = @CallGeneric.%T.1 (constants.%T)]
  229. // CHECK:STDOUT: %T.ref.loc8_29: type = name_ref T, @CallGeneric.%T.loc8 [symbolic = @CallGeneric.%T.1 (constants.%T)]
  230. // CHECK:STDOUT: %x.loc8_26.1: @CallGeneric.%T.1 (%T) = param x, runtime_param0
  231. // CHECK:STDOUT: @CallGeneric.%x: @CallGeneric.%T.1 (%T) = bind_name x, %x.loc8_26.1
  232. // CHECK:STDOUT: %T.ref.loc8_35: type = name_ref T, @CallGeneric.%T.loc8 [symbolic = @CallGeneric.%T.1 (constants.%T)]
  233. // CHECK:STDOUT: @CallGeneric.%return: ref @CallGeneric.%T.1 (%T) = var <return slot>
  234. // CHECK:STDOUT: }
  235. // CHECK:STDOUT: %CallGenericPtr.decl: %CallGenericPtr.type = fn_decl @CallGenericPtr [template = constants.%CallGenericPtr] {
  236. // CHECK:STDOUT: %T.loc12_19.1: type = param T, runtime_param<invalid>
  237. // CHECK:STDOUT: @CallGenericPtr.%T.loc12: type = bind_symbolic_name T 0, %T.loc12_19.1 [symbolic = @CallGenericPtr.%T.1 (constants.%T)]
  238. // CHECK:STDOUT: %T.ref.loc12_32: type = name_ref T, @CallGenericPtr.%T.loc12 [symbolic = @CallGenericPtr.%T.1 (constants.%T)]
  239. // CHECK:STDOUT: %.loc12_33: type = ptr_type %T [symbolic = @CallGenericPtr.%.1 (constants.%.2)]
  240. // CHECK:STDOUT: %x.loc12_29.1: @CallGenericPtr.%.1 (%.2) = param x, runtime_param0
  241. // CHECK:STDOUT: @CallGenericPtr.%x: @CallGenericPtr.%.1 (%.2) = bind_name x, %x.loc12_29.1
  242. // CHECK:STDOUT: %T.ref.loc12_39: type = name_ref T, @CallGenericPtr.%T.loc12 [symbolic = @CallGenericPtr.%T.1 (constants.%T)]
  243. // CHECK:STDOUT: %.loc12_40: type = ptr_type %T [symbolic = @CallGenericPtr.%.1 (constants.%.2)]
  244. // CHECK:STDOUT: @CallGenericPtr.%return: ref @CallGenericPtr.%.1 (%.2) = var <return slot>
  245. // CHECK:STDOUT: }
  246. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
  247. // CHECK:STDOUT: %CallSpecific.decl: %CallSpecific.type = fn_decl @CallSpecific [template = constants.%CallSpecific] {
  248. // CHECK:STDOUT: %C.ref.loc18_20: type = name_ref C, %C.decl [template = constants.%C]
  249. // CHECK:STDOUT: %x.loc18_17.1: %C = param x, runtime_param0
  250. // CHECK:STDOUT: @CallSpecific.%x: %C = bind_name x, %x.loc18_17.1
  251. // CHECK:STDOUT: %C.ref.loc18_26: type = name_ref C, %C.decl [template = constants.%C]
  252. // CHECK:STDOUT: @CallSpecific.%return: ref %C = var <return slot>
  253. // CHECK:STDOUT: }
  254. // CHECK:STDOUT: }
  255. // CHECK:STDOUT:
  256. // CHECK:STDOUT: class @C {
  257. // CHECK:STDOUT: !members:
  258. // CHECK:STDOUT: .Self = constants.%C
  259. // CHECK:STDOUT: }
  260. // CHECK:STDOUT:
  261. // CHECK:STDOUT: generic fn @Function(%T.loc4: type) {
  262. // CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)]
  263. // CHECK:STDOUT:
  264. // CHECK:STDOUT: !definition:
  265. // CHECK:STDOUT:
  266. // CHECK:STDOUT: fn[%T.loc4: type](%x: @Function.%T.1 (%T)) -> @Function.%T.1 (%T) {
  267. // CHECK:STDOUT: !entry:
  268. // CHECK:STDOUT: %x.ref: @Function.%T.1 (%T) = name_ref x, %x
  269. // CHECK:STDOUT: return %x.ref
  270. // CHECK:STDOUT: }
  271. // CHECK:STDOUT: }
  272. // CHECK:STDOUT:
  273. // CHECK:STDOUT: generic fn @CallGeneric(%T.loc8: type) {
  274. // CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)]
  275. // CHECK:STDOUT:
  276. // CHECK:STDOUT: !definition:
  277. // CHECK:STDOUT:
  278. // CHECK:STDOUT: fn(%T.loc8: type, %x: @CallGeneric.%T.1 (%T)) -> @CallGeneric.%T.1 (%T) {
  279. // CHECK:STDOUT: !entry:
  280. // CHECK:STDOUT: %Function.ref: %Function.type = name_ref Function, file.%Function.decl [template = constants.%Function]
  281. // CHECK:STDOUT: %x.ref: @CallGeneric.%T.1 (%T) = name_ref x, %x
  282. // CHECK:STDOUT: %Function.call: init @CallGeneric.%T.1 (%T) = call %Function.ref(%x.ref)
  283. // CHECK:STDOUT: %.loc9_21.1: @CallGeneric.%T.1 (%T) = value_of_initializer %Function.call
  284. // CHECK:STDOUT: %.loc9_21.2: @CallGeneric.%T.1 (%T) = converted %Function.call, %.loc9_21.1
  285. // CHECK:STDOUT: return %.loc9_21.2
  286. // CHECK:STDOUT: }
  287. // CHECK:STDOUT: }
  288. // CHECK:STDOUT:
  289. // CHECK:STDOUT: generic fn @CallGenericPtr(%T.loc12: type) {
  290. // CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)]
  291. // CHECK:STDOUT: %.1: type = ptr_type @CallGenericPtr.%T.1 (%T) [symbolic = %.1 (constants.%.2)]
  292. // CHECK:STDOUT:
  293. // CHECK:STDOUT: !definition:
  294. // CHECK:STDOUT:
  295. // CHECK:STDOUT: fn(%T.loc12: type, %x: @CallGenericPtr.%.1 (%.2)) -> @CallGenericPtr.%.1 (%.2) {
  296. // CHECK:STDOUT: !entry:
  297. // CHECK:STDOUT: %Function.ref: %Function.type = name_ref Function, file.%Function.decl [template = constants.%Function]
  298. // CHECK:STDOUT: %x.ref: @CallGenericPtr.%.1 (%.2) = name_ref x, %x
  299. // CHECK:STDOUT: %Function.call: init @CallGenericPtr.%.1 (%.2) = call %Function.ref(%x.ref)
  300. // CHECK:STDOUT: %.loc13_21.1: @CallGenericPtr.%.1 (%.2) = value_of_initializer %Function.call
  301. // CHECK:STDOUT: %.loc13_21.2: @CallGenericPtr.%.1 (%.2) = converted %Function.call, %.loc13_21.1
  302. // CHECK:STDOUT: return %.loc13_21.2
  303. // CHECK:STDOUT: }
  304. // CHECK:STDOUT: }
  305. // CHECK:STDOUT:
  306. // CHECK:STDOUT: fn @CallSpecific(%x: %C) -> %return: %C {
  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: %C = name_ref x, %x
  310. // CHECK:STDOUT: %.loc18: ref %C = splice_block %return {}
  311. // CHECK:STDOUT: %Function.call: init %C = call %Function.ref(%x.ref) to %.loc18
  312. // CHECK:STDOUT: return %Function.call to %return
  313. // CHECK:STDOUT: }
  314. // CHECK:STDOUT:
  315. // CHECK:STDOUT: specific @Function(constants.%T) {
  316. // CHECK:STDOUT: %T.1 => constants.%T
  317. // CHECK:STDOUT: }
  318. // CHECK:STDOUT:
  319. // CHECK:STDOUT: specific @CallGeneric(constants.%T) {
  320. // CHECK:STDOUT: %T.1 => constants.%T
  321. // CHECK:STDOUT: }
  322. // CHECK:STDOUT:
  323. // CHECK:STDOUT: specific @CallGenericPtr(constants.%T) {
  324. // CHECK:STDOUT: %T.1 => constants.%T
  325. // CHECK:STDOUT: %.1 => constants.%.2
  326. // CHECK:STDOUT: }
  327. // CHECK:STDOUT:
  328. // CHECK:STDOUT: specific @Function(constants.%.2) {
  329. // CHECK:STDOUT: %T.1 => constants.%.2
  330. // CHECK:STDOUT: }
  331. // CHECK:STDOUT:
  332. // CHECK:STDOUT: specific @Function(constants.%C) {
  333. // CHECK:STDOUT: %T.1 => constants.%C
  334. // CHECK:STDOUT: }
  335. // CHECK:STDOUT: