call_basic_depth.carbon 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/destroy.carbon
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/generic/call_basic_depth.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/generic/call_basic_depth.carbon
  12. class C {
  13. fn Cfn[unused self: Self, T:! type](unused x: T) {
  14. }
  15. }
  16. //@dump-sem-ir-begin
  17. fn F[T:! type](unused x: T) {
  18. }
  19. //@dump-sem-ir-end
  20. fn H[T:! type](x: T) {
  21. //@dump-sem-ir-begin
  22. F(x);
  23. //@dump-sem-ir-end
  24. }
  25. fn G[T:! type](x: T) {
  26. //@dump-sem-ir-begin
  27. H(x);
  28. F(x);
  29. //@dump-sem-ir-end
  30. var c: C;
  31. c.Cfn(x);
  32. }
  33. fn M() {
  34. var n: C;
  35. //@dump-sem-ir-begin
  36. F(n);
  37. G(n);
  38. //@dump-sem-ir-end
  39. }
  40. // CHECK:STDOUT: --- call_basic_depth.carbon
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: constants {
  43. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  44. // CHECK:STDOUT: %pattern_type.7c7: type = pattern_type %C [concrete]
  45. // CHECK:STDOUT: %pattern_type.98f: type = pattern_type type [concrete]
  46. // CHECK:STDOUT: %T: type = symbolic_binding T, 0 [symbolic]
  47. // CHECK:STDOUT: %pattern_type.51d: type = pattern_type %T [symbolic]
  48. // CHECK:STDOUT: %C.Cfn.type: type = fn_type @C.Cfn [concrete]
  49. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  50. // CHECK:STDOUT: %C.Cfn: %C.Cfn.type = struct_value () [concrete]
  51. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  52. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  53. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %T [symbolic]
  54. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  55. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  56. // CHECK:STDOUT: %H.type: type = fn_type @H [concrete]
  57. // CHECK:STDOUT: %H: %H.type = struct_value () [concrete]
  58. // CHECK:STDOUT: %F.specific_fn.643: <specific function> = specific_function %F, @F(%T) [symbolic]
  59. // CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
  60. // CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
  61. // CHECK:STDOUT: %H.specific_fn.965: <specific function> = specific_function %H, @H(%T) [symbolic]
  62. // CHECK:STDOUT: %F.specific_fn.540: <specific function> = specific_function %F, @F(%C) [concrete]
  63. // CHECK:STDOUT: %G.specific_fn: <specific function> = specific_function %G, @G(%C) [concrete]
  64. // CHECK:STDOUT: %H.specific_fn.d42: <specific function> = specific_function %H, @H(%C) [concrete]
  65. // CHECK:STDOUT: %C.Cfn.specific_fn.f5e: <specific function> = specific_function %C.Cfn, @C.Cfn(%C) [concrete]
  66. // CHECK:STDOUT: }
  67. // CHECK:STDOUT:
  68. // CHECK:STDOUT: file {
  69. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  70. // CHECK:STDOUT: %T.patt: %pattern_type.98f = symbolic_binding_pattern T, 0 [concrete]
  71. // CHECK:STDOUT: %x.patt: @F.%pattern_type (%pattern_type.51d) = value_binding_pattern x [concrete]
  72. // CHECK:STDOUT: %x.param_patt: @F.%pattern_type (%pattern_type.51d) = value_param_pattern %x.patt [concrete]
  73. // CHECK:STDOUT: } {
  74. // CHECK:STDOUT: %.loc19_10.1: type = splice_block %.loc19_10.2 [concrete = type] {
  75. // CHECK:STDOUT: <elided>
  76. // CHECK:STDOUT: %.loc19_10.2: type = type_literal type [concrete = type]
  77. // CHECK:STDOUT: }
  78. // CHECK:STDOUT: %T.loc19_6.2: type = symbolic_binding T, 0 [symbolic = %T.loc19_6.1 (constants.%T)]
  79. // CHECK:STDOUT: %x.param: @F.%T.loc19_6.1 (%T) = value_param call_param0
  80. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc19_6.2 [symbolic = %T.loc19_6.1 (constants.%T)]
  81. // CHECK:STDOUT: %x: @F.%T.loc19_6.1 (%T) = value_binding x, %x.param
  82. // CHECK:STDOUT: }
  83. // CHECK:STDOUT: }
  84. // CHECK:STDOUT:
  85. // CHECK:STDOUT: generic fn @F(%T.loc19_6.2: type) {
  86. // CHECK:STDOUT: %T.loc19_6.1: type = symbolic_binding T, 0 [symbolic = %T.loc19_6.1 (constants.%T)]
  87. // CHECK:STDOUT: %pattern_type: type = pattern_type %T.loc19_6.1 [symbolic = %pattern_type (constants.%pattern_type.51d)]
  88. // CHECK:STDOUT:
  89. // CHECK:STDOUT: !definition:
  90. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %T.loc19_6.1 [symbolic = %require_complete (constants.%require_complete)]
  91. // CHECK:STDOUT:
  92. // CHECK:STDOUT: fn(%x.param: @F.%T.loc19_6.1 (%T)) {
  93. // CHECK:STDOUT: !entry:
  94. // CHECK:STDOUT: return
  95. // CHECK:STDOUT: }
  96. // CHECK:STDOUT: }
  97. // CHECK:STDOUT:
  98. // CHECK:STDOUT: generic fn @H(%T.loc23_6.2: type) {
  99. // CHECK:STDOUT: <elided>
  100. // CHECK:STDOUT:
  101. // CHECK:STDOUT: !definition:
  102. // CHECK:STDOUT: <elided>
  103. // CHECK:STDOUT: %F.specific_fn.loc25_3.2: <specific function> = specific_function constants.%F, @F(%T.loc23_6.1) [symbolic = %F.specific_fn.loc25_3.2 (constants.%F.specific_fn.643)]
  104. // CHECK:STDOUT:
  105. // CHECK:STDOUT: fn(%x.param: @H.%T.loc23_6.1 (%T)) {
  106. // CHECK:STDOUT: !entry:
  107. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
  108. // CHECK:STDOUT: %x.ref: @H.%T.loc23_6.1 (%T) = name_ref x, %x
  109. // CHECK:STDOUT: %F.specific_fn.loc25_3.1: <specific function> = specific_function %F.ref, @F(constants.%T) [symbolic = %F.specific_fn.loc25_3.2 (constants.%F.specific_fn.643)]
  110. // CHECK:STDOUT: %F.call: init %empty_tuple.type = call %F.specific_fn.loc25_3.1(%x.ref)
  111. // CHECK:STDOUT: <elided>
  112. // CHECK:STDOUT: }
  113. // CHECK:STDOUT: }
  114. // CHECK:STDOUT:
  115. // CHECK:STDOUT: generic fn @G(%T.loc29_6.2: type) {
  116. // CHECK:STDOUT: <elided>
  117. // CHECK:STDOUT:
  118. // CHECK:STDOUT: !definition:
  119. // CHECK:STDOUT: <elided>
  120. // CHECK:STDOUT: %H.specific_fn.loc31_3.2: <specific function> = specific_function constants.%H, @H(%T.loc29_6.1) [symbolic = %H.specific_fn.loc31_3.2 (constants.%H.specific_fn.965)]
  121. // CHECK:STDOUT: %F.specific_fn.loc32_3.2: <specific function> = specific_function constants.%F, @F(%T.loc29_6.1) [symbolic = %F.specific_fn.loc32_3.2 (constants.%F.specific_fn.643)]
  122. // CHECK:STDOUT: <elided>
  123. // CHECK:STDOUT:
  124. // CHECK:STDOUT: fn(%x.param: @G.%T.loc29_6.1 (%T)) {
  125. // CHECK:STDOUT: !entry:
  126. // CHECK:STDOUT: %H.ref: %H.type = name_ref H, file.%H.decl [concrete = constants.%H]
  127. // CHECK:STDOUT: %x.ref.loc31: @G.%T.loc29_6.1 (%T) = name_ref x, %x
  128. // CHECK:STDOUT: %H.specific_fn.loc31_3.1: <specific function> = specific_function %H.ref, @H(constants.%T) [symbolic = %H.specific_fn.loc31_3.2 (constants.%H.specific_fn.965)]
  129. // CHECK:STDOUT: %H.call: init %empty_tuple.type = call %H.specific_fn.loc31_3.1(%x.ref.loc31)
  130. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
  131. // CHECK:STDOUT: %x.ref.loc32: @G.%T.loc29_6.1 (%T) = name_ref x, %x
  132. // CHECK:STDOUT: %F.specific_fn.loc32_3.1: <specific function> = specific_function %F.ref, @F(constants.%T) [symbolic = %F.specific_fn.loc32_3.2 (constants.%F.specific_fn.643)]
  133. // CHECK:STDOUT: %F.call: init %empty_tuple.type = call %F.specific_fn.loc32_3.1(%x.ref.loc32)
  134. // CHECK:STDOUT: <elided>
  135. // CHECK:STDOUT: }
  136. // CHECK:STDOUT: }
  137. // CHECK:STDOUT:
  138. // CHECK:STDOUT: fn @M() {
  139. // CHECK:STDOUT: !entry:
  140. // CHECK:STDOUT: <elided>
  141. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
  142. // CHECK:STDOUT: %n.ref.loc43: ref %C = name_ref n, %n
  143. // CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F.ref, @F(constants.%C) [concrete = constants.%F.specific_fn.540]
  144. // CHECK:STDOUT: %.loc43: %C = acquire_value %n.ref.loc43
  145. // CHECK:STDOUT: %F.call: init %empty_tuple.type = call %F.specific_fn(%.loc43)
  146. // CHECK:STDOUT: %G.ref: %G.type = name_ref G, file.%G.decl [concrete = constants.%G]
  147. // CHECK:STDOUT: %n.ref.loc44: ref %C = name_ref n, %n
  148. // CHECK:STDOUT: %G.specific_fn: <specific function> = specific_function %G.ref, @G(constants.%C) [concrete = constants.%G.specific_fn]
  149. // CHECK:STDOUT: %.loc44: %C = acquire_value %n.ref.loc44
  150. // CHECK:STDOUT: %G.call: init %empty_tuple.type = call %G.specific_fn(%.loc44)
  151. // CHECK:STDOUT: <elided>
  152. // CHECK:STDOUT: }
  153. // CHECK:STDOUT:
  154. // CHECK:STDOUT: specific @F(constants.%T) {
  155. // CHECK:STDOUT: %T.loc19_6.1 => constants.%T
  156. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.51d
  157. // CHECK:STDOUT:
  158. // CHECK:STDOUT: !definition:
  159. // CHECK:STDOUT: %require_complete => constants.%require_complete
  160. // CHECK:STDOUT: }
  161. // CHECK:STDOUT:
  162. // CHECK:STDOUT: specific @H(constants.%T) {
  163. // CHECK:STDOUT: %T.loc23_6.1 => constants.%T
  164. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.51d
  165. // CHECK:STDOUT:
  166. // CHECK:STDOUT: !definition:
  167. // CHECK:STDOUT: %require_complete => constants.%require_complete
  168. // CHECK:STDOUT: %F.specific_fn.loc25_3.2 => constants.%F.specific_fn.643
  169. // CHECK:STDOUT: }
  170. // CHECK:STDOUT:
  171. // CHECK:STDOUT: specific @G(constants.%T) {
  172. // CHECK:STDOUT: %T.loc29_6.1 => constants.%T
  173. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.51d
  174. // CHECK:STDOUT: }
  175. // CHECK:STDOUT:
  176. // CHECK:STDOUT: specific @F(constants.%C) {
  177. // CHECK:STDOUT: %T.loc19_6.1 => constants.%C
  178. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.7c7
  179. // CHECK:STDOUT:
  180. // CHECK:STDOUT: !definition:
  181. // CHECK:STDOUT: %require_complete => constants.%complete_type
  182. // CHECK:STDOUT: }
  183. // CHECK:STDOUT:
  184. // CHECK:STDOUT: specific @G(constants.%C) {
  185. // CHECK:STDOUT: %T.loc29_6.1 => constants.%C
  186. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.7c7
  187. // CHECK:STDOUT:
  188. // CHECK:STDOUT: !definition:
  189. // CHECK:STDOUT: %require_complete => constants.%complete_type
  190. // CHECK:STDOUT: %H.specific_fn.loc31_3.2 => constants.%H.specific_fn.d42
  191. // CHECK:STDOUT: %F.specific_fn.loc32_3.2 => constants.%F.specific_fn.540
  192. // CHECK:STDOUT: %C.Cfn.specific_fn.loc36_4.2 => constants.%C.Cfn.specific_fn.f5e
  193. // CHECK:STDOUT: }
  194. // CHECK:STDOUT:
  195. // CHECK:STDOUT: specific @H(constants.%C) {
  196. // CHECK:STDOUT: %T.loc23_6.1 => constants.%C
  197. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.7c7
  198. // CHECK:STDOUT:
  199. // CHECK:STDOUT: !definition:
  200. // CHECK:STDOUT: %require_complete => constants.%complete_type
  201. // CHECK:STDOUT: %F.specific_fn.loc25_3.2 => constants.%F.specific_fn.540
  202. // CHECK:STDOUT: }
  203. // CHECK:STDOUT: