inline.carbon 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  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/int.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/interop/cpp/function/inline.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interop/cpp/function/inline.carbon
  12. // ============================================================================
  13. // With definition
  14. // ============================================================================
  15. // --- with_definition.h
  16. inline void foo() {}
  17. // --- import_with_definition.carbon
  18. library "[[@TEST_NAME]]";
  19. import Cpp library "with_definition.h";
  20. fn MyF() {
  21. //@dump-sem-ir-begin
  22. Cpp.foo();
  23. //@dump-sem-ir-end
  24. }
  25. // ============================================================================
  26. // Without definition
  27. // ============================================================================
  28. // --- without_definition.h
  29. inline void foo();
  30. // --- todo_fail_import_without_definition.carbon
  31. library "[[@TEST_NAME]]";
  32. // TODO: Promote this warning to an error by default.
  33. // CHECK:STDERR: todo_fail_import_without_definition.carbon:[[@LINE+4]]:10: in file included here [InCppInclude]
  34. // CHECK:STDERR: ./without_definition.h:2:13: warning: inline function 'foo' is not defined [CppInteropParseWarning]
  35. // CHECK:STDERR: 2 | inline void foo();
  36. // CHECK:STDERR: | ^
  37. import Cpp library "without_definition.h";
  38. fn MyF() {
  39. //@dump-sem-ir-begin
  40. // CHECK:STDERR: todo_fail_import_without_definition.carbon:[[@LINE+4]]:11: note: used here [CppInteropParseNote]
  41. // CHECK:STDERR: 17 | Cpp.foo();
  42. // CHECK:STDERR: | ^
  43. // CHECK:STDERR:
  44. Cpp.foo();
  45. // Don't error on repeated calls.
  46. Cpp.foo();
  47. //@dump-sem-ir-end
  48. }
  49. // ============================================================================
  50. // automatic return type
  51. // ============================================================================
  52. // --- automatic_return_type.carbon
  53. library "[[@TEST_NAME]]";
  54. import Cpp inline '''
  55. inline auto WithoutThunk(int) -> auto { return 0; }
  56. inline auto ThunkOnArg(short) -> auto { return 0; }
  57. inline auto ThunkOnReturn(int) -> auto { short x = 0; return x; }
  58. inline auto ThunkOnBoth(short) -> auto { short x = 0; return x; }
  59. ''';
  60. fn MyF() {
  61. //@dump-sem-ir-begin
  62. let unused r1: i32 = Cpp.WithoutThunk(1);
  63. let unused r2: i32 = Cpp.ThunkOnArg(1);
  64. let unused r3: i16 = Cpp.ThunkOnReturn(1);
  65. let unused r4: i16 = Cpp.ThunkOnBoth(1);
  66. //@dump-sem-ir-end
  67. }
  68. // CHECK:STDOUT: --- import_with_definition.carbon
  69. // CHECK:STDOUT:
  70. // CHECK:STDOUT: constants {
  71. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  72. // CHECK:STDOUT: %foo.cpp_overload_set.type: type = cpp_overload_set_type @foo.cpp_overload_set [concrete]
  73. // CHECK:STDOUT: %foo.cpp_overload_set.value: %foo.cpp_overload_set.type = cpp_overload_set_value @foo.cpp_overload_set [concrete]
  74. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  75. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  76. // CHECK:STDOUT: }
  77. // CHECK:STDOUT:
  78. // CHECK:STDOUT: imports {
  79. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  80. // CHECK:STDOUT: .foo = %foo.cpp_overload_set.value
  81. // CHECK:STDOUT: import Cpp//...
  82. // CHECK:STDOUT: }
  83. // CHECK:STDOUT: %foo.cpp_overload_set.value: %foo.cpp_overload_set.type = cpp_overload_set_value @foo.cpp_overload_set [concrete = constants.%foo.cpp_overload_set.value]
  84. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {} {}
  85. // CHECK:STDOUT: }
  86. // CHECK:STDOUT:
  87. // CHECK:STDOUT: fn @MyF() {
  88. // CHECK:STDOUT: !entry:
  89. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  90. // CHECK:STDOUT: %foo.ref: %foo.cpp_overload_set.type = name_ref foo, imports.%foo.cpp_overload_set.value [concrete = constants.%foo.cpp_overload_set.value]
  91. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call imports.%foo.decl()
  92. // CHECK:STDOUT: <elided>
  93. // CHECK:STDOUT: }
  94. // CHECK:STDOUT:
  95. // CHECK:STDOUT: --- todo_fail_import_without_definition.carbon
  96. // CHECK:STDOUT:
  97. // CHECK:STDOUT: constants {
  98. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  99. // CHECK:STDOUT: %foo.cpp_overload_set.type: type = cpp_overload_set_type @foo.cpp_overload_set [concrete]
  100. // CHECK:STDOUT: %foo.cpp_overload_set.value: %foo.cpp_overload_set.type = cpp_overload_set_value @foo.cpp_overload_set [concrete]
  101. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  102. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  103. // CHECK:STDOUT: }
  104. // CHECK:STDOUT:
  105. // CHECK:STDOUT: imports {
  106. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  107. // CHECK:STDOUT: .foo = %foo.cpp_overload_set.value
  108. // CHECK:STDOUT: import Cpp//...
  109. // CHECK:STDOUT: }
  110. // CHECK:STDOUT: %foo.cpp_overload_set.value: %foo.cpp_overload_set.type = cpp_overload_set_value @foo.cpp_overload_set [concrete = constants.%foo.cpp_overload_set.value]
  111. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {} {}
  112. // CHECK:STDOUT: }
  113. // CHECK:STDOUT:
  114. // CHECK:STDOUT: fn @MyF() {
  115. // CHECK:STDOUT: !entry:
  116. // CHECK:STDOUT: %Cpp.ref.loc17: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  117. // CHECK:STDOUT: %foo.ref.loc17: %foo.cpp_overload_set.type = name_ref foo, imports.%foo.cpp_overload_set.value [concrete = constants.%foo.cpp_overload_set.value]
  118. // CHECK:STDOUT: %foo.call.loc17: init %empty_tuple.type = call imports.%foo.decl()
  119. // CHECK:STDOUT: %Cpp.ref.loc20: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  120. // CHECK:STDOUT: %foo.ref.loc20: %foo.cpp_overload_set.type = name_ref foo, imports.%foo.cpp_overload_set.value [concrete = constants.%foo.cpp_overload_set.value]
  121. // CHECK:STDOUT: %foo.call.loc20: init %empty_tuple.type = call imports.%foo.decl()
  122. // CHECK:STDOUT: <elided>
  123. // CHECK:STDOUT: }
  124. // CHECK:STDOUT:
  125. // CHECK:STDOUT: --- automatic_return_type.carbon
  126. // CHECK:STDOUT:
  127. // CHECK:STDOUT: constants {
  128. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  129. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  130. // CHECK:STDOUT: %N: Core.IntLiteral = symbolic_binding N, 0 [symbolic]
  131. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  132. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  133. // CHECK:STDOUT: %WithoutThunk.cpp_overload_set.type: type = cpp_overload_set_type @WithoutThunk.cpp_overload_set [concrete]
  134. // CHECK:STDOUT: %WithoutThunk.cpp_overload_set.value: %WithoutThunk.cpp_overload_set.type = cpp_overload_set_value @WithoutThunk.cpp_overload_set [concrete]
  135. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  136. // CHECK:STDOUT: %WithoutThunk.type: type = fn_type @WithoutThunk [concrete]
  137. // CHECK:STDOUT: %WithoutThunk: %WithoutThunk.type = struct_value () [concrete]
  138. // CHECK:STDOUT: %ImplicitAs.type.e8c: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
  139. // CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic]
  140. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.4e6: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To) [symbolic]
  141. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.3c2: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.4e6 = struct_value () [symbolic]
  142. // CHECK:STDOUT: %ImplicitAs.impl_witness.6bc: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.74f, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete]
  143. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.e0d: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete]
  144. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.e0d = struct_value () [concrete]
  145. // CHECK:STDOUT: %ImplicitAs.facet.b94: %ImplicitAs.type.e8c = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.6bc) [concrete]
  146. // CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.b37: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs(%i32, %ImplicitAs.facet.b94) [concrete]
  147. // CHECK:STDOUT: %.545: type = fn_type_with_self_type %ImplicitAs.WithSelf.Convert.type.b37, %ImplicitAs.facet.b94 [concrete]
  148. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.215: <bound method> = bound_method %int_1.5b8, %Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5 [concrete]
  149. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn.709: <specific function> = specific_function %Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5, @Core.IntLiteral.as.ImplicitAs.impl.Convert(%int_32) [concrete]
  150. // CHECK:STDOUT: %bound_method.38b: <bound method> = bound_method %int_1.5b8, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn.709 [concrete]
  151. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
  152. // CHECK:STDOUT: %ThunkOnArg.cpp_overload_set.type: type = cpp_overload_set_type @ThunkOnArg.cpp_overload_set [concrete]
  153. // CHECK:STDOUT: %ThunkOnArg.cpp_overload_set.value: %ThunkOnArg.cpp_overload_set.type = cpp_overload_set_value @ThunkOnArg.cpp_overload_set [concrete]
  154. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete]
  155. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(%int_16) [concrete]
  156. // CHECK:STDOUT: %pattern_type.2f8: type = pattern_type %i16 [concrete]
  157. // CHECK:STDOUT: %ptr.251: type = ptr_type %i16 [concrete]
  158. // CHECK:STDOUT: %ThunkOnArg__carbon_thunk.type: type = fn_type @ThunkOnArg__carbon_thunk [concrete]
  159. // CHECK:STDOUT: %ThunkOnArg__carbon_thunk: %ThunkOnArg__carbon_thunk.type = struct_value () [concrete]
  160. // CHECK:STDOUT: %ImplicitAs.type.9fb: type = facet_type <@ImplicitAs, @ImplicitAs(%i16)> [concrete]
  161. // CHECK:STDOUT: %ImplicitAs.impl_witness.882: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.74f, @Core.IntLiteral.as.ImplicitAs.impl(%int_16) [concrete]
  162. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.c54: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_16) [concrete]
  163. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.8d9: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.c54 = struct_value () [concrete]
  164. // CHECK:STDOUT: %ImplicitAs.facet.44d: %ImplicitAs.type.9fb = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.882) [concrete]
  165. // CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.89b: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs(%i16, %ImplicitAs.facet.44d) [concrete]
  166. // CHECK:STDOUT: %.3ce: type = fn_type_with_self_type %ImplicitAs.WithSelf.Convert.type.89b, %ImplicitAs.facet.44d [concrete]
  167. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.7e8: <bound method> = bound_method %int_1.5b8, %Core.IntLiteral.as.ImplicitAs.impl.Convert.8d9 [concrete]
  168. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn.a76: <specific function> = specific_function %Core.IntLiteral.as.ImplicitAs.impl.Convert.8d9, @Core.IntLiteral.as.ImplicitAs.impl.Convert(%int_16) [concrete]
  169. // CHECK:STDOUT: %bound_method.576: <bound method> = bound_method %int_1.5b8, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn.a76 [concrete]
  170. // CHECK:STDOUT: %int_1.f90: %i16 = int_value 1 [concrete]
  171. // CHECK:STDOUT: %Copy.type: type = facet_type <@Copy> [concrete]
  172. // CHECK:STDOUT: %Int.as.Copy.impl.Op.type.824: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%N) [symbolic]
  173. // CHECK:STDOUT: %Int.as.Copy.impl.Op.9b9: %Int.as.Copy.impl.Op.type.824 = struct_value () [symbolic]
  174. // CHECK:STDOUT: %Copy.impl_witness.e99: <witness> = impl_witness imports.%Copy.impl_witness_table.e76, @Int.as.Copy.impl(%int_16) [concrete]
  175. // CHECK:STDOUT: %Int.as.Copy.impl.Op.type.97f: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%int_16) [concrete]
  176. // CHECK:STDOUT: %Int.as.Copy.impl.Op.0da: %Int.as.Copy.impl.Op.type.97f = struct_value () [concrete]
  177. // CHECK:STDOUT: %Copy.facet: %Copy.type = facet_value %i16, (%Copy.impl_witness.e99) [concrete]
  178. // CHECK:STDOUT: %Copy.WithSelf.Op.type.d1f: type = fn_type @Copy.WithSelf.Op, @Copy(%Copy.facet) [concrete]
  179. // CHECK:STDOUT: %.eb3: type = fn_type_with_self_type %Copy.WithSelf.Op.type.d1f, %Copy.facet [concrete]
  180. // CHECK:STDOUT: %Int.as.Copy.impl.Op.bound: <bound method> = bound_method %int_1.f90, %Int.as.Copy.impl.Op.0da [concrete]
  181. // CHECK:STDOUT: %Int.as.Copy.impl.Op.specific_fn: <specific function> = specific_function %Int.as.Copy.impl.Op.0da, @Int.as.Copy.impl.Op(%int_16) [concrete]
  182. // CHECK:STDOUT: %bound_method.a48: <bound method> = bound_method %int_1.f90, %Int.as.Copy.impl.Op.specific_fn [concrete]
  183. // CHECK:STDOUT: %ThunkOnReturn.cpp_overload_set.type: type = cpp_overload_set_type @ThunkOnReturn.cpp_overload_set [concrete]
  184. // CHECK:STDOUT: %ThunkOnReturn.cpp_overload_set.value: %ThunkOnReturn.cpp_overload_set.type = cpp_overload_set_value @ThunkOnReturn.cpp_overload_set [concrete]
  185. // CHECK:STDOUT: %ThunkOnReturn__carbon_thunk.type: type = fn_type @ThunkOnReturn__carbon_thunk [concrete]
  186. // CHECK:STDOUT: %ThunkOnReturn__carbon_thunk: %ThunkOnReturn__carbon_thunk.type = struct_value () [concrete]
  187. // CHECK:STDOUT: %ThunkOnBoth.cpp_overload_set.type: type = cpp_overload_set_type @ThunkOnBoth.cpp_overload_set [concrete]
  188. // CHECK:STDOUT: %ThunkOnBoth.cpp_overload_set.value: %ThunkOnBoth.cpp_overload_set.type = cpp_overload_set_value @ThunkOnBoth.cpp_overload_set [concrete]
  189. // CHECK:STDOUT: %ThunkOnBoth__carbon_thunk.type: type = fn_type @ThunkOnBoth__carbon_thunk [concrete]
  190. // CHECK:STDOUT: %ThunkOnBoth__carbon_thunk: %ThunkOnBoth__carbon_thunk.type = struct_value () [concrete]
  191. // CHECK:STDOUT: %DestroyOp.type: type = fn_type @DestroyOp [concrete]
  192. // CHECK:STDOUT: %DestroyOp: %DestroyOp.type = struct_value () [concrete]
  193. // CHECK:STDOUT: }
  194. // CHECK:STDOUT:
  195. // CHECK:STDOUT: imports {
  196. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  197. // CHECK:STDOUT: .WithoutThunk = %WithoutThunk.cpp_overload_set.value
  198. // CHECK:STDOUT: .ThunkOnArg = %ThunkOnArg.cpp_overload_set.value
  199. // CHECK:STDOUT: .ThunkOnReturn = %ThunkOnReturn.cpp_overload_set.value
  200. // CHECK:STDOUT: .ThunkOnBoth = %ThunkOnBoth.cpp_overload_set.value
  201. // CHECK:STDOUT: import Cpp//...
  202. // CHECK:STDOUT: }
  203. // CHECK:STDOUT: %WithoutThunk.cpp_overload_set.value: %WithoutThunk.cpp_overload_set.type = cpp_overload_set_value @WithoutThunk.cpp_overload_set [concrete = constants.%WithoutThunk.cpp_overload_set.value]
  204. // CHECK:STDOUT: %WithoutThunk.decl: %WithoutThunk.type = fn_decl @WithoutThunk [concrete = constants.%WithoutThunk] {
  205. // CHECK:STDOUT: <elided>
  206. // CHECK:STDOUT: } {
  207. // CHECK:STDOUT: <elided>
  208. // CHECK:STDOUT: }
  209. // CHECK:STDOUT: %Core.import_ref.42d: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.4e6) = import_ref Core//prelude/parts/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.3c2)]
  210. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.74f = impl_witness_table (%Core.import_ref.42d), @Core.IntLiteral.as.ImplicitAs.impl [concrete]
  211. // CHECK:STDOUT: %ThunkOnArg.cpp_overload_set.value: %ThunkOnArg.cpp_overload_set.type = cpp_overload_set_value @ThunkOnArg.cpp_overload_set [concrete = constants.%ThunkOnArg.cpp_overload_set.value]
  212. // CHECK:STDOUT: %ThunkOnArg__carbon_thunk.decl: %ThunkOnArg__carbon_thunk.type = fn_decl @ThunkOnArg__carbon_thunk [concrete = constants.%ThunkOnArg__carbon_thunk] {
  213. // CHECK:STDOUT: <elided>
  214. // CHECK:STDOUT: } {
  215. // CHECK:STDOUT: <elided>
  216. // CHECK:STDOUT: }
  217. // CHECK:STDOUT: %Core.import_ref.18d: @Int.as.Copy.impl.%Int.as.Copy.impl.Op.type (%Int.as.Copy.impl.Op.type.824) = import_ref Core//prelude/parts/int, loc{{\d+_\d+}}, loaded [symbolic = @Int.as.Copy.impl.%Int.as.Copy.impl.Op (constants.%Int.as.Copy.impl.Op.9b9)]
  218. // CHECK:STDOUT: %Copy.impl_witness_table.e76 = impl_witness_table (%Core.import_ref.18d), @Int.as.Copy.impl [concrete]
  219. // CHECK:STDOUT: %ThunkOnReturn.cpp_overload_set.value: %ThunkOnReturn.cpp_overload_set.type = cpp_overload_set_value @ThunkOnReturn.cpp_overload_set [concrete = constants.%ThunkOnReturn.cpp_overload_set.value]
  220. // CHECK:STDOUT: %ThunkOnReturn__carbon_thunk.decl: %ThunkOnReturn__carbon_thunk.type = fn_decl @ThunkOnReturn__carbon_thunk [concrete = constants.%ThunkOnReturn__carbon_thunk] {
  221. // CHECK:STDOUT: <elided>
  222. // CHECK:STDOUT: } {
  223. // CHECK:STDOUT: <elided>
  224. // CHECK:STDOUT: }
  225. // CHECK:STDOUT: %ThunkOnBoth.cpp_overload_set.value: %ThunkOnBoth.cpp_overload_set.type = cpp_overload_set_value @ThunkOnBoth.cpp_overload_set [concrete = constants.%ThunkOnBoth.cpp_overload_set.value]
  226. // CHECK:STDOUT: %ThunkOnBoth__carbon_thunk.decl: %ThunkOnBoth__carbon_thunk.type = fn_decl @ThunkOnBoth__carbon_thunk [concrete = constants.%ThunkOnBoth__carbon_thunk] {
  227. // CHECK:STDOUT: <elided>
  228. // CHECK:STDOUT: } {
  229. // CHECK:STDOUT: <elided>
  230. // CHECK:STDOUT: }
  231. // CHECK:STDOUT: }
  232. // CHECK:STDOUT:
  233. // CHECK:STDOUT: fn @MyF() {
  234. // CHECK:STDOUT: !entry:
  235. // CHECK:STDOUT: name_binding_decl {
  236. // CHECK:STDOUT: %r1.patt: %pattern_type.7ce = value_binding_pattern r1 [concrete]
  237. // CHECK:STDOUT: }
  238. // CHECK:STDOUT: %Cpp.ref.loc13: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  239. // CHECK:STDOUT: %WithoutThunk.ref: %WithoutThunk.cpp_overload_set.type = name_ref WithoutThunk, imports.%WithoutThunk.cpp_overload_set.value [concrete = constants.%WithoutThunk.cpp_overload_set.value]
  240. // CHECK:STDOUT: %int_1.loc13: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  241. // CHECK:STDOUT: %impl.elem0.loc13: %.545 = impl_witness_access constants.%ImplicitAs.impl_witness.6bc, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5]
  242. // CHECK:STDOUT: %bound_method.loc13_41.1: <bound method> = bound_method %int_1.loc13, %impl.elem0.loc13 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.215]
  243. // CHECK:STDOUT: %specific_fn.loc13: <specific function> = specific_function %impl.elem0.loc13, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn.709]
  244. // CHECK:STDOUT: %bound_method.loc13_41.2: <bound method> = bound_method %int_1.loc13, %specific_fn.loc13 [concrete = constants.%bound_method.38b]
  245. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc13: init %i32 = call %bound_method.loc13_41.2(%int_1.loc13) [concrete = constants.%int_1.5d2]
  246. // CHECK:STDOUT: %.loc13_41.1: %i32 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc13 [concrete = constants.%int_1.5d2]
  247. // CHECK:STDOUT: %.loc13_41.2: %i32 = converted %int_1.loc13, %.loc13_41.1 [concrete = constants.%int_1.5d2]
  248. // CHECK:STDOUT: %WithoutThunk.call: init %i32 = call imports.%WithoutThunk.decl(%.loc13_41.2)
  249. // CHECK:STDOUT: %.loc13_18: type = splice_block %i32.loc13 [concrete = constants.%i32] {
  250. // CHECK:STDOUT: %int_32.loc13: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  251. // CHECK:STDOUT: %i32.loc13: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  252. // CHECK:STDOUT: }
  253. // CHECK:STDOUT: %.loc13_42.1: %i32 = value_of_initializer %WithoutThunk.call
  254. // CHECK:STDOUT: %.loc13_42.2: %i32 = converted %WithoutThunk.call, %.loc13_42.1
  255. // CHECK:STDOUT: %r1: %i32 = value_binding r1, %.loc13_42.2
  256. // CHECK:STDOUT: name_binding_decl {
  257. // CHECK:STDOUT: %r2.patt: %pattern_type.7ce = value_binding_pattern r2 [concrete]
  258. // CHECK:STDOUT: }
  259. // CHECK:STDOUT: %Cpp.ref.loc14: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  260. // CHECK:STDOUT: %ThunkOnArg.ref: %ThunkOnArg.cpp_overload_set.type = name_ref ThunkOnArg, imports.%ThunkOnArg.cpp_overload_set.value [concrete = constants.%ThunkOnArg.cpp_overload_set.value]
  261. // CHECK:STDOUT: %int_1.loc14: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  262. // CHECK:STDOUT: %impl.elem0.loc14_39.1: %.3ce = impl_witness_access constants.%ImplicitAs.impl_witness.882, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.8d9]
  263. // CHECK:STDOUT: %bound_method.loc14_39.1: <bound method> = bound_method %int_1.loc14, %impl.elem0.loc14_39.1 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.7e8]
  264. // CHECK:STDOUT: %specific_fn.loc14_39.1: <specific function> = specific_function %impl.elem0.loc14_39.1, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_16) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn.a76]
  265. // CHECK:STDOUT: %bound_method.loc14_39.2: <bound method> = bound_method %int_1.loc14, %specific_fn.loc14_39.1 [concrete = constants.%bound_method.576]
  266. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc14: init %i16 = call %bound_method.loc14_39.2(%int_1.loc14) [concrete = constants.%int_1.f90]
  267. // CHECK:STDOUT: %.loc14_39.1: %i16 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc14 [concrete = constants.%int_1.f90]
  268. // CHECK:STDOUT: %.loc14_39.2: %i16 = converted %int_1.loc14, %.loc14_39.1 [concrete = constants.%int_1.f90]
  269. // CHECK:STDOUT: %.loc14_39.3: ref %i16 = temporary_storage
  270. // CHECK:STDOUT: %impl.elem0.loc14_39.2: %.eb3 = impl_witness_access constants.%Copy.impl_witness.e99, element0 [concrete = constants.%Int.as.Copy.impl.Op.0da]
  271. // CHECK:STDOUT: %bound_method.loc14_39.3: <bound method> = bound_method %.loc14_39.2, %impl.elem0.loc14_39.2 [concrete = constants.%Int.as.Copy.impl.Op.bound]
  272. // CHECK:STDOUT: %specific_fn.loc14_39.2: <specific function> = specific_function %impl.elem0.loc14_39.2, @Int.as.Copy.impl.Op(constants.%int_16) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn]
  273. // CHECK:STDOUT: %bound_method.loc14_39.4: <bound method> = bound_method %.loc14_39.2, %specific_fn.loc14_39.2 [concrete = constants.%bound_method.a48]
  274. // CHECK:STDOUT: %Int.as.Copy.impl.Op.call.loc14: init %i16 = call %bound_method.loc14_39.4(%.loc14_39.2) [concrete = constants.%int_1.f90]
  275. // CHECK:STDOUT: %.loc14_39.4: ref %i16 = temporary %.loc14_39.3, %Int.as.Copy.impl.Op.call.loc14
  276. // CHECK:STDOUT: %addr.loc14: %ptr.251 = addr_of %.loc14_39.4
  277. // CHECK:STDOUT: %ThunkOnArg__carbon_thunk.call: init %i32 = call imports.%ThunkOnArg__carbon_thunk.decl(%addr.loc14)
  278. // CHECK:STDOUT: %.loc14_18: type = splice_block %i32.loc14 [concrete = constants.%i32] {
  279. // CHECK:STDOUT: %int_32.loc14: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  280. // CHECK:STDOUT: %i32.loc14: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  281. // CHECK:STDOUT: }
  282. // CHECK:STDOUT: %.loc14_40.1: %i32 = value_of_initializer %ThunkOnArg__carbon_thunk.call
  283. // CHECK:STDOUT: %.loc14_40.2: %i32 = converted %ThunkOnArg__carbon_thunk.call, %.loc14_40.1
  284. // CHECK:STDOUT: %r2: %i32 = value_binding r2, %.loc14_40.2
  285. // CHECK:STDOUT: name_binding_decl {
  286. // CHECK:STDOUT: %r3.patt: %pattern_type.2f8 = value_binding_pattern r3 [concrete]
  287. // CHECK:STDOUT: }
  288. // CHECK:STDOUT: %Cpp.ref.loc15: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  289. // CHECK:STDOUT: %ThunkOnReturn.ref: %ThunkOnReturn.cpp_overload_set.type = name_ref ThunkOnReturn, imports.%ThunkOnReturn.cpp_overload_set.value [concrete = constants.%ThunkOnReturn.cpp_overload_set.value]
  290. // CHECK:STDOUT: %int_1.loc15: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  291. // CHECK:STDOUT: %impl.elem0.loc15: %.545 = impl_witness_access constants.%ImplicitAs.impl_witness.6bc, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5]
  292. // CHECK:STDOUT: %bound_method.loc15_42.1: <bound method> = bound_method %int_1.loc15, %impl.elem0.loc15 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.215]
  293. // CHECK:STDOUT: %specific_fn.loc15: <specific function> = specific_function %impl.elem0.loc15, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn.709]
  294. // CHECK:STDOUT: %bound_method.loc15_42.2: <bound method> = bound_method %int_1.loc15, %specific_fn.loc15 [concrete = constants.%bound_method.38b]
  295. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc15: init %i32 = call %bound_method.loc15_42.2(%int_1.loc15) [concrete = constants.%int_1.5d2]
  296. // CHECK:STDOUT: %.loc15_42.1: %i32 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc15 [concrete = constants.%int_1.5d2]
  297. // CHECK:STDOUT: %.loc15_42.2: %i32 = converted %int_1.loc15, %.loc15_42.1 [concrete = constants.%int_1.5d2]
  298. // CHECK:STDOUT: %.loc15_43.1: ref %i16 = temporary_storage
  299. // CHECK:STDOUT: %addr.loc15: %ptr.251 = addr_of %.loc15_43.1
  300. // CHECK:STDOUT: %ThunkOnReturn__carbon_thunk.call: init %empty_tuple.type = call imports.%ThunkOnReturn__carbon_thunk.decl(%.loc15_42.2, %addr.loc15)
  301. // CHECK:STDOUT: %.loc15_43.2: init %i16 to %.loc15_43.1 = mark_in_place_init %ThunkOnReturn__carbon_thunk.call
  302. // CHECK:STDOUT: %.loc15_18: type = splice_block %i16.loc15 [concrete = constants.%i16] {
  303. // CHECK:STDOUT: %int_16.loc15: Core.IntLiteral = int_value 16 [concrete = constants.%int_16]
  304. // CHECK:STDOUT: %i16.loc15: type = class_type @Int, @Int(constants.%int_16) [concrete = constants.%i16]
  305. // CHECK:STDOUT: }
  306. // CHECK:STDOUT: %.loc15_43.3: ref %i16 = temporary %.loc15_43.1, %.loc15_43.2
  307. // CHECK:STDOUT: %.loc15_43.4: %i16 = acquire_value %.loc15_43.3
  308. // CHECK:STDOUT: %r3: %i16 = value_binding r3, %.loc15_43.4
  309. // CHECK:STDOUT: name_binding_decl {
  310. // CHECK:STDOUT: %r4.patt: %pattern_type.2f8 = value_binding_pattern r4 [concrete]
  311. // CHECK:STDOUT: }
  312. // CHECK:STDOUT: %Cpp.ref.loc16: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  313. // CHECK:STDOUT: %ThunkOnBoth.ref: %ThunkOnBoth.cpp_overload_set.type = name_ref ThunkOnBoth, imports.%ThunkOnBoth.cpp_overload_set.value [concrete = constants.%ThunkOnBoth.cpp_overload_set.value]
  314. // CHECK:STDOUT: %int_1.loc16: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  315. // CHECK:STDOUT: %impl.elem0.loc16_40.1: %.3ce = impl_witness_access constants.%ImplicitAs.impl_witness.882, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.8d9]
  316. // CHECK:STDOUT: %bound_method.loc16_40.1: <bound method> = bound_method %int_1.loc16, %impl.elem0.loc16_40.1 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.7e8]
  317. // CHECK:STDOUT: %specific_fn.loc16_40.1: <specific function> = specific_function %impl.elem0.loc16_40.1, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_16) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn.a76]
  318. // CHECK:STDOUT: %bound_method.loc16_40.2: <bound method> = bound_method %int_1.loc16, %specific_fn.loc16_40.1 [concrete = constants.%bound_method.576]
  319. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc16: init %i16 = call %bound_method.loc16_40.2(%int_1.loc16) [concrete = constants.%int_1.f90]
  320. // CHECK:STDOUT: %.loc16_40.1: %i16 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc16 [concrete = constants.%int_1.f90]
  321. // CHECK:STDOUT: %.loc16_40.2: %i16 = converted %int_1.loc16, %.loc16_40.1 [concrete = constants.%int_1.f90]
  322. // CHECK:STDOUT: %.loc16_40.3: ref %i16 = temporary_storage
  323. // CHECK:STDOUT: %impl.elem0.loc16_40.2: %.eb3 = impl_witness_access constants.%Copy.impl_witness.e99, element0 [concrete = constants.%Int.as.Copy.impl.Op.0da]
  324. // CHECK:STDOUT: %bound_method.loc16_40.3: <bound method> = bound_method %.loc16_40.2, %impl.elem0.loc16_40.2 [concrete = constants.%Int.as.Copy.impl.Op.bound]
  325. // CHECK:STDOUT: %specific_fn.loc16_40.2: <specific function> = specific_function %impl.elem0.loc16_40.2, @Int.as.Copy.impl.Op(constants.%int_16) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn]
  326. // CHECK:STDOUT: %bound_method.loc16_40.4: <bound method> = bound_method %.loc16_40.2, %specific_fn.loc16_40.2 [concrete = constants.%bound_method.a48]
  327. // CHECK:STDOUT: %Int.as.Copy.impl.Op.call.loc16: init %i16 = call %bound_method.loc16_40.4(%.loc16_40.2) [concrete = constants.%int_1.f90]
  328. // CHECK:STDOUT: %.loc16_40.4: ref %i16 = temporary %.loc16_40.3, %Int.as.Copy.impl.Op.call.loc16
  329. // CHECK:STDOUT: %addr.loc16_41.1: %ptr.251 = addr_of %.loc16_40.4
  330. // CHECK:STDOUT: %.loc16_41.1: ref %i16 = temporary_storage
  331. // CHECK:STDOUT: %addr.loc16_41.2: %ptr.251 = addr_of %.loc16_41.1
  332. // CHECK:STDOUT: %ThunkOnBoth__carbon_thunk.call: init %empty_tuple.type = call imports.%ThunkOnBoth__carbon_thunk.decl(%addr.loc16_41.1, %addr.loc16_41.2)
  333. // CHECK:STDOUT: %.loc16_41.2: init %i16 to %.loc16_41.1 = mark_in_place_init %ThunkOnBoth__carbon_thunk.call
  334. // CHECK:STDOUT: %.loc16_18: type = splice_block %i16.loc16 [concrete = constants.%i16] {
  335. // CHECK:STDOUT: %int_16.loc16: Core.IntLiteral = int_value 16 [concrete = constants.%int_16]
  336. // CHECK:STDOUT: %i16.loc16: type = class_type @Int, @Int(constants.%int_16) [concrete = constants.%i16]
  337. // CHECK:STDOUT: }
  338. // CHECK:STDOUT: %.loc16_41.3: ref %i16 = temporary %.loc16_41.1, %.loc16_41.2
  339. // CHECK:STDOUT: %.loc16_41.4: %i16 = acquire_value %.loc16_41.3
  340. // CHECK:STDOUT: %r4: %i16 = value_binding r4, %.loc16_41.4
  341. // CHECK:STDOUT: %DestroyOp.bound.loc16_41: <bound method> = bound_method %.loc16_41.3, constants.%DestroyOp
  342. // CHECK:STDOUT: %DestroyOp.call.loc16_41: init %empty_tuple.type = call %DestroyOp.bound.loc16_41(%.loc16_41.3)
  343. // CHECK:STDOUT: %DestroyOp.bound.loc16_40: <bound method> = bound_method %.loc16_40.4, constants.%DestroyOp
  344. // CHECK:STDOUT: %DestroyOp.call.loc16_40: init %empty_tuple.type = call %DestroyOp.bound.loc16_40(%.loc16_40.4)
  345. // CHECK:STDOUT: %DestroyOp.bound.loc15: <bound method> = bound_method %.loc15_43.3, constants.%DestroyOp
  346. // CHECK:STDOUT: %DestroyOp.call.loc15: init %empty_tuple.type = call %DestroyOp.bound.loc15(%.loc15_43.3)
  347. // CHECK:STDOUT: %DestroyOp.bound.loc14: <bound method> = bound_method %.loc14_39.4, constants.%DestroyOp
  348. // CHECK:STDOUT: %DestroyOp.call.loc14: init %empty_tuple.type = call %DestroyOp.bound.loc14(%.loc14_39.4)
  349. // CHECK:STDOUT: <elided>
  350. // CHECK:STDOUT: }
  351. // CHECK:STDOUT:
  352. // CHECK:STDOUT: fn @DestroyOp(%self.param: ref %i16) = "no_op";
  353. // CHECK:STDOUT: