import_thunk.carbon 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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/lower/testdata/impl/import_thunk.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/impl/import_thunk.carbon
  12. // --- thunk.carbon
  13. library "[[@TEST_NAME]]";
  14. class A { var a: i32; }
  15. class B { var b: i32; }
  16. class C { var c: i32; }
  17. impl A as Core.ImplicitAs(B) {
  18. fn Convert[self: A]() -> B { return {.b = self.a}; }
  19. }
  20. impl B as Core.ImplicitAs(C) {
  21. fn Convert[self: B]() -> C { return {.c = self.b}; }
  22. }
  23. interface I {
  24. fn F(a: A) -> C;
  25. }
  26. impl () as I {
  27. fn F(b: B) -> B { return {.b = b.b}; }
  28. }
  29. // --- call_thunk.carbon
  30. library "[[@TEST_NAME]]";
  31. import library "thunk";
  32. fn Test(a: A) -> C {
  33. return ().(I.F)(a);
  34. }
  35. // --- thunk_for_imported_interface.carbon
  36. library "[[@TEST_NAME]]";
  37. import library "thunk";
  38. class X {}
  39. impl X as I {
  40. fn F(b: B) -> B { return {.b = b.b}; }
  41. }
  42. // --- call_thunk_for_imported_interface.carbon
  43. library "[[@TEST_NAME]]";
  44. import library "thunk";
  45. import library "thunk_for_imported_interface";
  46. fn Test(a: A) -> C {
  47. return X.(I.F)(a);
  48. }
  49. // CHECK:STDOUT: ; ModuleID = 'thunk.carbon'
  50. // CHECK:STDOUT: source_filename = "thunk.carbon"
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: ; Function Attrs: nounwind
  53. // CHECK:STDOUT: define void @"_CConvert.A.Main:ImplicitAs.707dbe5ae2414d29.Core"(ptr sret({ i32 }) %return, ptr %self) #0 !dbg !4 {
  54. // CHECK:STDOUT: entry:
  55. // CHECK:STDOUT: %.loc9_49.1.a = getelementptr inbounds nuw { i32 }, ptr %self, i32 0, i32 0, !dbg !10
  56. // CHECK:STDOUT: %.loc9_49.2 = load i32, ptr %.loc9_49.1.a, align 4, !dbg !10
  57. // CHECK:STDOUT: %.loc9_51.2.b = getelementptr inbounds nuw { i32 }, ptr %return, i32 0, i32 0, !dbg !11
  58. // CHECK:STDOUT: store i32 %.loc9_49.2, ptr %.loc9_51.2.b, align 4, !dbg !11
  59. // CHECK:STDOUT: ret void, !dbg !12
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: ; Function Attrs: nounwind
  63. // CHECK:STDOUT: define void @"_CConvert.B.Main:ImplicitAs.0c4ab795cec6cb27.Core"(ptr sret({ i32 }) %return, ptr %self) #0 !dbg !13 {
  64. // CHECK:STDOUT: entry:
  65. // CHECK:STDOUT: %.loc12_49.1.b = getelementptr inbounds nuw { i32 }, ptr %self, i32 0, i32 0, !dbg !16
  66. // CHECK:STDOUT: %.loc12_49.2 = load i32, ptr %.loc12_49.1.b, align 4, !dbg !16
  67. // CHECK:STDOUT: %.loc12_51.2.c = getelementptr inbounds nuw { i32 }, ptr %return, i32 0, i32 0, !dbg !17
  68. // CHECK:STDOUT: store i32 %.loc12_49.2, ptr %.loc12_51.2.c, align 4, !dbg !17
  69. // CHECK:STDOUT: ret void, !dbg !18
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT:
  72. // CHECK:STDOUT: ; Function Attrs: nounwind
  73. // CHECK:STDOUT: define void @"_CF.61ea2aba74ab3bf1:I.Main"(ptr sret({ i32 }) %return, ptr %b) #0 !dbg !19 {
  74. // CHECK:STDOUT: entry:
  75. // CHECK:STDOUT: %.loc20_35.1.b = getelementptr inbounds nuw { i32 }, ptr %b, i32 0, i32 0, !dbg !22
  76. // CHECK:STDOUT: %.loc20_35.2 = load i32, ptr %.loc20_35.1.b, align 4, !dbg !22
  77. // CHECK:STDOUT: %.loc20_37.2.b = getelementptr inbounds nuw { i32 }, ptr %return, i32 0, i32 0, !dbg !23
  78. // CHECK:STDOUT: store i32 %.loc20_35.2, ptr %.loc20_37.2.b, align 4, !dbg !23
  79. // CHECK:STDOUT: ret void, !dbg !24
  80. // CHECK:STDOUT: }
  81. // CHECK:STDOUT:
  82. // CHECK:STDOUT: ; Function Attrs: alwaysinline nounwind
  83. // CHECK:STDOUT: define void @"_CF:thunk.61ea2aba74ab3bf1:I.Main"(ptr sret({ i32 }) %return, ptr %a) #1 !dbg !25 {
  84. // CHECK:STDOUT: entry:
  85. // CHECK:STDOUT: %.loc20_19.1.temp = alloca { i32 }, align 8, !dbg !28
  86. // CHECK:STDOUT: %.loc16_9.1.temp = alloca { i32 }, align 8, !dbg !29
  87. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc20_19.1.temp), !dbg !28
  88. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc16_9.1.temp), !dbg !29
  89. // CHECK:STDOUT: call void @"_CConvert.A.Main:ImplicitAs.707dbe5ae2414d29.Core"(ptr %.loc16_9.1.temp, ptr %a), !dbg !29
  90. // CHECK:STDOUT: call void @"_CF.61ea2aba74ab3bf1:I.Main"(ptr %.loc20_19.1.temp, ptr %.loc16_9.1.temp), !dbg !28
  91. // CHECK:STDOUT: call void @"_CConvert.B.Main:ImplicitAs.0c4ab795cec6cb27.Core"(ptr %return, ptr %.loc20_19.1.temp), !dbg !28
  92. // CHECK:STDOUT: ret void, !dbg !28
  93. // CHECK:STDOUT: }
  94. // CHECK:STDOUT:
  95. // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
  96. // CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #2
  97. // CHECK:STDOUT:
  98. // CHECK:STDOUT: ; uselistorder directives
  99. // CHECK:STDOUT: uselistorder ptr @llvm.lifetime.start.p0, { 1, 0 }
  100. // CHECK:STDOUT:
  101. // CHECK:STDOUT: attributes #0 = { nounwind }
  102. // CHECK:STDOUT: attributes #1 = { alwaysinline nounwind }
  103. // CHECK:STDOUT: attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
  104. // CHECK:STDOUT:
  105. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
  106. // CHECK:STDOUT: !llvm.dbg.cu = !{!2}
  107. // CHECK:STDOUT:
  108. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  109. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  110. // CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  111. // CHECK:STDOUT: !3 = !DIFile(filename: "thunk.carbon", directory: "")
  112. // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.A.Main:ImplicitAs.707dbe5ae2414d29.Core", scope: null, file: !3, line: 9, type: !5, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !8)
  113. // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
  114. // CHECK:STDOUT: !6 = !{!7, !7}
  115. // CHECK:STDOUT: !7 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 8)
  116. // CHECK:STDOUT: !8 = !{!9}
  117. // CHECK:STDOUT: !9 = !DILocalVariable(arg: 1, scope: !4, type: !7)
  118. // CHECK:STDOUT: !10 = !DILocation(line: 9, column: 45, scope: !4)
  119. // CHECK:STDOUT: !11 = !DILocation(line: 9, column: 39, scope: !4)
  120. // CHECK:STDOUT: !12 = !DILocation(line: 9, column: 32, scope: !4)
  121. // CHECK:STDOUT: !13 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.B.Main:ImplicitAs.0c4ab795cec6cb27.Core", scope: null, file: !3, line: 12, type: !5, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !14)
  122. // CHECK:STDOUT: !14 = !{!15}
  123. // CHECK:STDOUT: !15 = !DILocalVariable(arg: 1, scope: !13, type: !7)
  124. // CHECK:STDOUT: !16 = !DILocation(line: 12, column: 45, scope: !13)
  125. // CHECK:STDOUT: !17 = !DILocation(line: 12, column: 39, scope: !13)
  126. // CHECK:STDOUT: !18 = !DILocation(line: 12, column: 32, scope: !13)
  127. // CHECK:STDOUT: !19 = distinct !DISubprogram(name: "F", linkageName: "_CF.61ea2aba74ab3bf1:I.Main", scope: null, file: !3, line: 20, type: !5, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !20)
  128. // CHECK:STDOUT: !20 = !{!21}
  129. // CHECK:STDOUT: !21 = !DILocalVariable(arg: 1, scope: !19, type: !7)
  130. // CHECK:STDOUT: !22 = !DILocation(line: 20, column: 34, scope: !19)
  131. // CHECK:STDOUT: !23 = !DILocation(line: 20, column: 28, scope: !19)
  132. // CHECK:STDOUT: !24 = !DILocation(line: 20, column: 21, scope: !19)
  133. // CHECK:STDOUT: !25 = distinct !DISubprogram(name: "F", linkageName: "_CF:thunk.61ea2aba74ab3bf1:I.Main", scope: null, file: !3, line: 20, type: !5, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !26)
  134. // CHECK:STDOUT: !26 = !{!27}
  135. // CHECK:STDOUT: !27 = !DILocalVariable(arg: 1, scope: !25, type: !7)
  136. // CHECK:STDOUT: !28 = !DILocation(line: 20, column: 3, scope: !25)
  137. // CHECK:STDOUT: !29 = !DILocation(line: 16, column: 8, scope: !25)
  138. // CHECK:STDOUT: ; ModuleID = 'call_thunk.carbon'
  139. // CHECK:STDOUT: source_filename = "call_thunk.carbon"
  140. // CHECK:STDOUT:
  141. // CHECK:STDOUT: ; Function Attrs: nounwind
  142. // CHECK:STDOUT: define void @_CTest.Main(ptr sret({ i32 }) %return, ptr %a) #0 !dbg !4 {
  143. // CHECK:STDOUT: entry:
  144. // CHECK:STDOUT: %.loc7_20.1.temp = alloca { i32 }, align 8, !dbg !10
  145. // CHECK:STDOUT: %.loc7_20.2.temp = alloca { i32 }, align 8, !dbg !10
  146. // CHECK:STDOUT: %.loc7_19.1.temp = alloca { i32 }, align 8, !dbg !11
  147. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc7_20.1.temp), !dbg !10
  148. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc7_20.2.temp), !dbg !10
  149. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc7_19.1.temp), !dbg !11
  150. // CHECK:STDOUT: call void @"_CConvert.A.Main:ImplicitAs.707dbe5ae2414d29.Core"(ptr %.loc7_19.1.temp, ptr %a), !dbg !11
  151. // CHECK:STDOUT: call void @"_CF.61ea2aba74ab3bf1:I.Main"(ptr %.loc7_20.2.temp, ptr %.loc7_19.1.temp), !dbg !10
  152. // CHECK:STDOUT: call void @"_CConvert.B.Main:ImplicitAs.0c4ab795cec6cb27.Core"(ptr %return, ptr %.loc7_20.2.temp), !dbg !12
  153. // CHECK:STDOUT: ret void, !dbg !12
  154. // CHECK:STDOUT: }
  155. // CHECK:STDOUT:
  156. // CHECK:STDOUT: declare void @"_CF:thunk.61ea2aba74ab3bf1:I.Main"(ptr sret({ i32 }), ptr)
  157. // CHECK:STDOUT:
  158. // CHECK:STDOUT: declare void @"_CF.61ea2aba74ab3bf1:I.Main"(ptr sret({ i32 }), ptr)
  159. // CHECK:STDOUT:
  160. // CHECK:STDOUT: declare void @"_CConvert.A.Main:ImplicitAs.707dbe5ae2414d29.Core"(ptr sret({ i32 }), ptr)
  161. // CHECK:STDOUT:
  162. // CHECK:STDOUT: declare void @"_CConvert.B.Main:ImplicitAs.0c4ab795cec6cb27.Core"(ptr sret({ i32 }), ptr)
  163. // CHECK:STDOUT:
  164. // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
  165. // CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #1
  166. // CHECK:STDOUT:
  167. // CHECK:STDOUT: ; uselistorder directives
  168. // CHECK:STDOUT: uselistorder ptr @llvm.lifetime.start.p0, { 2, 1, 0 }
  169. // CHECK:STDOUT:
  170. // CHECK:STDOUT: attributes #0 = { nounwind }
  171. // CHECK:STDOUT: attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
  172. // CHECK:STDOUT:
  173. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
  174. // CHECK:STDOUT: !llvm.dbg.cu = !{!2}
  175. // CHECK:STDOUT:
  176. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  177. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  178. // CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  179. // CHECK:STDOUT: !3 = !DIFile(filename: "call_thunk.carbon", directory: "")
  180. // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Test", linkageName: "_CTest.Main", scope: null, file: !3, line: 6, type: !5, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !8)
  181. // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
  182. // CHECK:STDOUT: !6 = !{!7, !7}
  183. // CHECK:STDOUT: !7 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 8)
  184. // CHECK:STDOUT: !8 = !{!9}
  185. // CHECK:STDOUT: !9 = !DILocalVariable(arg: 1, scope: !4, type: !7)
  186. // CHECK:STDOUT: !10 = !DILocation(line: 7, column: 10, scope: !4)
  187. // CHECK:STDOUT: !11 = !DILocation(line: 7, column: 19, scope: !4)
  188. // CHECK:STDOUT: !12 = !DILocation(line: 7, column: 3, scope: !4)
  189. // CHECK:STDOUT: ; ModuleID = 'thunk_for_imported_interface.carbon'
  190. // CHECK:STDOUT: source_filename = "thunk_for_imported_interface.carbon"
  191. // CHECK:STDOUT:
  192. // CHECK:STDOUT: ; Function Attrs: nounwind
  193. // CHECK:STDOUT: define void @"_CF.X.Main:I.Main"(ptr sret({ i32 }) %return, ptr %b) #0 !dbg !4 {
  194. // CHECK:STDOUT: entry:
  195. // CHECK:STDOUT: %.loc9_35.1.b = getelementptr inbounds nuw { i32 }, ptr %b, i32 0, i32 0, !dbg !10
  196. // CHECK:STDOUT: %.loc9_35.2 = load i32, ptr %.loc9_35.1.b, align 4, !dbg !10
  197. // CHECK:STDOUT: %.loc9_37.2.b = getelementptr inbounds nuw { i32 }, ptr %return, i32 0, i32 0, !dbg !11
  198. // CHECK:STDOUT: store i32 %.loc9_35.2, ptr %.loc9_37.2.b, align 4, !dbg !11
  199. // CHECK:STDOUT: ret void, !dbg !12
  200. // CHECK:STDOUT: }
  201. // CHECK:STDOUT:
  202. // CHECK:STDOUT: ; Function Attrs: alwaysinline nounwind
  203. // CHECK:STDOUT: define void @"_CF:thunk.X.Main:I.Main"(ptr sret({ i32 }) %return, ptr %a) #1 !dbg !13 {
  204. // CHECK:STDOUT: entry:
  205. // CHECK:STDOUT: %.loc9_19.1.temp = alloca { i32 }, align 8, !dbg !16
  206. // CHECK:STDOUT: %.2.temp = alloca { i32 }, align 8
  207. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc9_19.1.temp), !dbg !16
  208. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.2.temp)
  209. // CHECK:STDOUT: call void @"_CConvert.A.Main:ImplicitAs.707dbe5ae2414d29.Core"(ptr %.2.temp, ptr %a), !dbg !17
  210. // CHECK:STDOUT: call void @"_CF.X.Main:I.Main"(ptr %.loc9_19.1.temp, ptr %.2.temp), !dbg !16
  211. // CHECK:STDOUT: call void @"_CConvert.B.Main:ImplicitAs.0c4ab795cec6cb27.Core"(ptr %return, ptr %.loc9_19.1.temp), !dbg !16
  212. // CHECK:STDOUT: ret void, !dbg !16
  213. // CHECK:STDOUT: }
  214. // CHECK:STDOUT:
  215. // CHECK:STDOUT: declare void @"_CConvert.A.Main:ImplicitAs.707dbe5ae2414d29.Core"(ptr sret({ i32 }), ptr)
  216. // CHECK:STDOUT:
  217. // CHECK:STDOUT: declare void @"_CConvert.B.Main:ImplicitAs.0c4ab795cec6cb27.Core"(ptr sret({ i32 }), ptr)
  218. // CHECK:STDOUT:
  219. // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
  220. // CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #2
  221. // CHECK:STDOUT:
  222. // CHECK:STDOUT: ; uselistorder directives
  223. // CHECK:STDOUT: uselistorder ptr @llvm.lifetime.start.p0, { 1, 0 }
  224. // CHECK:STDOUT:
  225. // CHECK:STDOUT: attributes #0 = { nounwind }
  226. // CHECK:STDOUT: attributes #1 = { alwaysinline nounwind }
  227. // CHECK:STDOUT: attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
  228. // CHECK:STDOUT:
  229. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
  230. // CHECK:STDOUT: !llvm.dbg.cu = !{!2}
  231. // CHECK:STDOUT:
  232. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  233. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  234. // CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  235. // CHECK:STDOUT: !3 = !DIFile(filename: "thunk_for_imported_interface.carbon", directory: "")
  236. // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", linkageName: "_CF.X.Main:I.Main", scope: null, file: !3, line: 9, type: !5, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !8)
  237. // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
  238. // CHECK:STDOUT: !6 = !{!7, !7}
  239. // CHECK:STDOUT: !7 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 8)
  240. // CHECK:STDOUT: !8 = !{!9}
  241. // CHECK:STDOUT: !9 = !DILocalVariable(arg: 1, scope: !4, type: !7)
  242. // CHECK:STDOUT: !10 = !DILocation(line: 9, column: 34, scope: !4)
  243. // CHECK:STDOUT: !11 = !DILocation(line: 9, column: 28, scope: !4)
  244. // CHECK:STDOUT: !12 = !DILocation(line: 9, column: 21, scope: !4)
  245. // CHECK:STDOUT: !13 = distinct !DISubprogram(name: "F", linkageName: "_CF:thunk.X.Main:I.Main", scope: null, file: !3, line: 9, type: !5, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !14)
  246. // CHECK:STDOUT: !14 = !{!15}
  247. // CHECK:STDOUT: !15 = !DILocalVariable(arg: 1, scope: !13, type: !7)
  248. // CHECK:STDOUT: !16 = !DILocation(line: 9, column: 3, scope: !13)
  249. // CHECK:STDOUT: !17 = !DILocation(line: 4294967295, scope: !13)
  250. // CHECK:STDOUT: ; ModuleID = 'call_thunk_for_imported_interface.carbon'
  251. // CHECK:STDOUT: source_filename = "call_thunk_for_imported_interface.carbon"
  252. // CHECK:STDOUT:
  253. // CHECK:STDOUT: ; Function Attrs: nounwind
  254. // CHECK:STDOUT: define void @_CTest.Main(ptr sret({ i32 }) %return, ptr %a) #0 !dbg !4 {
  255. // CHECK:STDOUT: entry:
  256. // CHECK:STDOUT: %.loc8_19.1.temp = alloca { i32 }, align 8, !dbg !10
  257. // CHECK:STDOUT: %.loc8_19.2.temp = alloca { i32 }, align 8, !dbg !10
  258. // CHECK:STDOUT: %.loc8_18.1.temp = alloca { i32 }, align 8, !dbg !11
  259. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc8_19.1.temp), !dbg !10
  260. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc8_19.2.temp), !dbg !10
  261. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc8_18.1.temp), !dbg !11
  262. // CHECK:STDOUT: call void @"_CConvert.A.Main:ImplicitAs.707dbe5ae2414d29.Core"(ptr %.loc8_18.1.temp, ptr %a), !dbg !11
  263. // CHECK:STDOUT: call void @"_CF.X.Main:I.Main"(ptr %.loc8_19.2.temp, ptr %.loc8_18.1.temp), !dbg !10
  264. // CHECK:STDOUT: call void @"_CConvert.B.Main:ImplicitAs.0c4ab795cec6cb27.Core"(ptr %return, ptr %.loc8_19.2.temp), !dbg !12
  265. // CHECK:STDOUT: ret void, !dbg !12
  266. // CHECK:STDOUT: }
  267. // CHECK:STDOUT:
  268. // CHECK:STDOUT: declare void @"_CF:thunk.X.Main:I.Main"(ptr sret({ i32 }), ptr)
  269. // CHECK:STDOUT:
  270. // CHECK:STDOUT: declare void @"_CF.X.Main:I.Main"(ptr sret({ i32 }), ptr)
  271. // CHECK:STDOUT:
  272. // CHECK:STDOUT: declare void @"_CConvert.A.Main:ImplicitAs.707dbe5ae2414d29.Core"(ptr sret({ i32 }), ptr)
  273. // CHECK:STDOUT:
  274. // CHECK:STDOUT: declare void @"_CConvert.B.Main:ImplicitAs.0c4ab795cec6cb27.Core"(ptr sret({ i32 }), ptr)
  275. // CHECK:STDOUT:
  276. // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
  277. // CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #1
  278. // CHECK:STDOUT:
  279. // CHECK:STDOUT: ; uselistorder directives
  280. // CHECK:STDOUT: uselistorder ptr @llvm.lifetime.start.p0, { 2, 1, 0 }
  281. // CHECK:STDOUT:
  282. // CHECK:STDOUT: attributes #0 = { nounwind }
  283. // CHECK:STDOUT: attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
  284. // CHECK:STDOUT:
  285. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
  286. // CHECK:STDOUT: !llvm.dbg.cu = !{!2}
  287. // CHECK:STDOUT:
  288. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  289. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  290. // CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  291. // CHECK:STDOUT: !3 = !DIFile(filename: "call_thunk_for_imported_interface.carbon", directory: "")
  292. // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Test", linkageName: "_CTest.Main", scope: null, file: !3, line: 7, type: !5, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !8)
  293. // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
  294. // CHECK:STDOUT: !6 = !{!7, !7}
  295. // CHECK:STDOUT: !7 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 8)
  296. // CHECK:STDOUT: !8 = !{!9}
  297. // CHECK:STDOUT: !9 = !DILocalVariable(arg: 1, scope: !4, type: !7)
  298. // CHECK:STDOUT: !10 = !DILocation(line: 8, column: 10, scope: !4)
  299. // CHECK:STDOUT: !11 = !DILocation(line: 8, column: 18, scope: !4)
  300. // CHECK:STDOUT: !12 = !DILocation(line: 8, column: 3, scope: !4)