function.carbon 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  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/full.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/interop/cpp/reverse/function.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/interop/cpp/reverse/function.carbon
  12. // --- other.carbon
  13. package Other;
  14. fn NoArgs() {}
  15. fn BoolArg(a: bool) {
  16. a;
  17. }
  18. fn IntArg(a: i32) {
  19. a;
  20. }
  21. fn FloatArg(a: f32) {
  22. a;
  23. }
  24. fn IntReturn() -> i32 {
  25. return 123;
  26. }
  27. // --- function.carbon
  28. library "[[@TEST_NAME]]";
  29. import Other;
  30. import Cpp inline '''
  31. int G() {
  32. Carbon::Other::NoArgs();
  33. Carbon::Other::BoolArg(true);
  34. Carbon::Other::IntArg(123);
  35. Carbon::Other::FloatArg(1.5);
  36. return Carbon::Other::IntReturn();
  37. }
  38. ''';
  39. // --- single_file.carbon
  40. library "[[@TEST_NAME]]";
  41. import Cpp;
  42. fn F() {}
  43. inline Cpp '''
  44. inline void G1() {
  45. Carbon::F();
  46. }
  47. // Call an inline function indirectly to ensure declarations are getting
  48. // properly registered with the CodeGen consumer.
  49. inline void G2() {
  50. G1();
  51. }
  52. ''';
  53. fn H() { Cpp.G2(); }
  54. // CHECK:STDOUT: ; ModuleID = 'other.carbon'
  55. // CHECK:STDOUT: source_filename = "other.carbon"
  56. // CHECK:STDOUT:
  57. // CHECK:STDOUT: ; Function Attrs: nounwind
  58. // CHECK:STDOUT: define void @_CNoArgs.Other() #0 !dbg !4 {
  59. // CHECK:STDOUT: entry:
  60. // CHECK:STDOUT: ret void, !dbg !7
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT:
  63. // CHECK:STDOUT: ; Function Attrs: nounwind
  64. // CHECK:STDOUT: define void @_CBoolArg.Other(i1 %a) #0 !dbg !8 {
  65. // CHECK:STDOUT: entry:
  66. // CHECK:STDOUT: ret void, !dbg !14
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: ; Function Attrs: nounwind
  70. // CHECK:STDOUT: define void @_CIntArg.Other(i32 %a) #0 !dbg !15 {
  71. // CHECK:STDOUT: entry:
  72. // CHECK:STDOUT: ret void, !dbg !21
  73. // CHECK:STDOUT: }
  74. // CHECK:STDOUT:
  75. // CHECK:STDOUT: ; Function Attrs: nounwind
  76. // CHECK:STDOUT: define void @_CFloatArg.Other(float %a) #0 !dbg !22 {
  77. // CHECK:STDOUT: entry:
  78. // CHECK:STDOUT: ret void, !dbg !25
  79. // CHECK:STDOUT: }
  80. // CHECK:STDOUT:
  81. // CHECK:STDOUT: ; Function Attrs: nounwind
  82. // CHECK:STDOUT: define i32 @_CIntReturn.Other() #0 !dbg !26 {
  83. // CHECK:STDOUT: entry:
  84. // CHECK:STDOUT: ret i32 123, !dbg !29
  85. // CHECK:STDOUT: }
  86. // CHECK:STDOUT:
  87. // CHECK:STDOUT: attributes #0 = { nounwind }
  88. // CHECK:STDOUT:
  89. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
  90. // CHECK:STDOUT: !llvm.dbg.cu = !{!2}
  91. // CHECK:STDOUT:
  92. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  93. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  94. // CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  95. // CHECK:STDOUT: !3 = !DIFile(filename: "other.carbon", directory: "")
  96. // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "NoArgs", linkageName: "_CNoArgs.Other", scope: null, file: !3, line: 2, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  97. // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
  98. // CHECK:STDOUT: !6 = !{null}
  99. // CHECK:STDOUT: !7 = !DILocation(line: 2, column: 1, scope: !4)
  100. // CHECK:STDOUT: !8 = distinct !DISubprogram(name: "BoolArg", linkageName: "_CBoolArg.Other", scope: null, file: !3, line: 3, type: !9, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !12)
  101. // CHECK:STDOUT: !9 = !DISubroutineType(types: !10)
  102. // CHECK:STDOUT: !10 = !{null, !11}
  103. // CHECK:STDOUT: !11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
  104. // CHECK:STDOUT: !12 = !{!13}
  105. // CHECK:STDOUT: !13 = !DILocalVariable(arg: 1, scope: !8, type: !11)
  106. // CHECK:STDOUT: !14 = !DILocation(line: 3, column: 1, scope: !8)
  107. // CHECK:STDOUT: !15 = distinct !DISubprogram(name: "IntArg", linkageName: "_CIntArg.Other", scope: null, file: !3, line: 6, type: !16, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !19)
  108. // CHECK:STDOUT: !16 = !DISubroutineType(types: !17)
  109. // CHECK:STDOUT: !17 = !{null, !18}
  110. // CHECK:STDOUT: !18 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
  111. // CHECK:STDOUT: !19 = !{!20}
  112. // CHECK:STDOUT: !20 = !DILocalVariable(arg: 1, scope: !15, type: !18)
  113. // CHECK:STDOUT: !21 = !DILocation(line: 6, column: 1, scope: !15)
  114. // CHECK:STDOUT: !22 = distinct !DISubprogram(name: "FloatArg", linkageName: "_CFloatArg.Other", scope: null, file: !3, line: 9, type: !9, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !23)
  115. // CHECK:STDOUT: !23 = !{!24}
  116. // CHECK:STDOUT: !24 = !DILocalVariable(arg: 1, scope: !22, type: !11)
  117. // CHECK:STDOUT: !25 = !DILocation(line: 9, column: 1, scope: !22)
  118. // CHECK:STDOUT: !26 = distinct !DISubprogram(name: "IntReturn", linkageName: "_CIntReturn.Other", scope: null, file: !3, line: 12, type: !27, spFlags: DISPFlagDefinition, unit: !2)
  119. // CHECK:STDOUT: !27 = !DISubroutineType(types: !28)
  120. // CHECK:STDOUT: !28 = !{!18}
  121. // CHECK:STDOUT: !29 = !DILocation(line: 13, column: 3, scope: !26)
  122. // CHECK:STDOUT: ; ModuleID = 'function.carbon'
  123. // CHECK:STDOUT: source_filename = "function.carbon"
  124. // CHECK:STDOUT: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
  125. // CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu"
  126. // CHECK:STDOUT:
  127. // CHECK:STDOUT: ; Function Attrs: mustprogress uwtable
  128. // CHECK:STDOUT: define dso_local noundef i32 @_Z1Gv() #0 {
  129. // CHECK:STDOUT: entry:
  130. // CHECK:STDOUT: call void @_ZN6Carbon5OtherL6NoArgsEv()
  131. // CHECK:STDOUT: call void @_ZN6Carbon5OtherL7BoolArgEb(i1 noundef zeroext true)
  132. // CHECK:STDOUT: call void @_ZN6Carbon5OtherL6IntArgEi(i32 noundef 123)
  133. // CHECK:STDOUT: call void @_ZN6Carbon5OtherL8FloatArgEf(float noundef 1.500000e+00)
  134. // CHECK:STDOUT: %call = call noundef i32 @_ZN6Carbon5OtherL9IntReturnEv()
  135. // CHECK:STDOUT: ret i32 %call
  136. // CHECK:STDOUT: }
  137. // CHECK:STDOUT:
  138. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress nounwind uwtable
  139. // CHECK:STDOUT: define internal void @_ZN6Carbon5OtherL6NoArgsEv() #1 {
  140. // CHECK:STDOUT: entry:
  141. // CHECK:STDOUT: call void @_CNoArgs__carbon_thunk.Other()
  142. // CHECK:STDOUT: ret void
  143. // CHECK:STDOUT: }
  144. // CHECK:STDOUT:
  145. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress nounwind uwtable
  146. // CHECK:STDOUT: define internal void @_ZN6Carbon5OtherL7BoolArgEb(i1 noundef zeroext %0) #1 {
  147. // CHECK:STDOUT: entry:
  148. // CHECK:STDOUT: %.addr = alloca i8, align 1
  149. // CHECK:STDOUT: %storedv = zext i1 %0 to i8
  150. // CHECK:STDOUT: store i8 %storedv, ptr %.addr, align 1, !tbaa !11
  151. // CHECK:STDOUT: call void @_CBoolArg__carbon_thunk.Other(ptr noundef nonnull align 1 dereferenceable(1) %.addr)
  152. // CHECK:STDOUT: ret void
  153. // CHECK:STDOUT: }
  154. // CHECK:STDOUT:
  155. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress nounwind uwtable
  156. // CHECK:STDOUT: define internal void @_ZN6Carbon5OtherL6IntArgEi(i32 noundef %0) #1 {
  157. // CHECK:STDOUT: entry:
  158. // CHECK:STDOUT: %.addr = alloca i32, align 4
  159. // CHECK:STDOUT: store i32 %0, ptr %.addr, align 4, !tbaa !7
  160. // CHECK:STDOUT: call void @_CIntArg__carbon_thunk.Other(ptr noundef nonnull align 4 dereferenceable(4) %.addr)
  161. // CHECK:STDOUT: ret void
  162. // CHECK:STDOUT: }
  163. // CHECK:STDOUT:
  164. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress nounwind uwtable
  165. // CHECK:STDOUT: define internal void @_ZN6Carbon5OtherL8FloatArgEf(float noundef %0) #1 {
  166. // CHECK:STDOUT: entry:
  167. // CHECK:STDOUT: %.addr = alloca float, align 4
  168. // CHECK:STDOUT: store float %0, ptr %.addr, align 4, !tbaa !13
  169. // CHECK:STDOUT: call void @_CFloatArg__carbon_thunk.Other(ptr noundef nonnull align 4 dereferenceable(4) %.addr)
  170. // CHECK:STDOUT: ret void
  171. // CHECK:STDOUT: }
  172. // CHECK:STDOUT:
  173. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress nounwind uwtable
  174. // CHECK:STDOUT: define internal noundef i32 @_ZN6Carbon5OtherL9IntReturnEv() #1 {
  175. // CHECK:STDOUT: entry:
  176. // CHECK:STDOUT: %retval = alloca i32, align 4
  177. // CHECK:STDOUT: call void @_CIntReturn__carbon_thunk.Other(ptr noundef nonnull align 4 dereferenceable(4) %retval)
  178. // CHECK:STDOUT: %0 = load i32, ptr %retval, align 4
  179. // CHECK:STDOUT: ret i32 %0
  180. // CHECK:STDOUT: }
  181. // CHECK:STDOUT:
  182. // CHECK:STDOUT: declare void @_CNoArgs.Other()
  183. // CHECK:STDOUT:
  184. // CHECK:STDOUT: ; Function Attrs: nounwind
  185. // CHECK:STDOUT: define void @_CNoArgs__carbon_thunk.Other() #2 !dbg !15 {
  186. // CHECK:STDOUT: entry:
  187. // CHECK:STDOUT: call void @_CNoArgs.Other(), !dbg !19
  188. // CHECK:STDOUT: ret void, !dbg !19
  189. // CHECK:STDOUT: }
  190. // CHECK:STDOUT:
  191. // CHECK:STDOUT: declare void @_CBoolArg.Other(i1)
  192. // CHECK:STDOUT:
  193. // CHECK:STDOUT: ; Function Attrs: nounwind
  194. // CHECK:STDOUT: define void @_CBoolArg__carbon_thunk.Other(ptr %_) #2 !dbg !20 {
  195. // CHECK:STDOUT: entry:
  196. // CHECK:STDOUT: %.1 = load i8, ptr %_, align 1, !dbg !26
  197. // CHECK:STDOUT: %.11 = trunc i8 %.1 to i1, !dbg !26
  198. // CHECK:STDOUT: call void @_CBoolArg.Other(i1 %.11), !dbg !26
  199. // CHECK:STDOUT: ret void, !dbg !26
  200. // CHECK:STDOUT: }
  201. // CHECK:STDOUT:
  202. // CHECK:STDOUT: declare void @_CIntArg.Other(i32)
  203. // CHECK:STDOUT:
  204. // CHECK:STDOUT: ; Function Attrs: nounwind
  205. // CHECK:STDOUT: define void @_CIntArg__carbon_thunk.Other(ptr %_) #2 !dbg !27 {
  206. // CHECK:STDOUT: entry:
  207. // CHECK:STDOUT: %.1 = load i32, ptr %_, align 4, !dbg !33
  208. // CHECK:STDOUT: call void @_CIntArg.Other(i32 %.1), !dbg !33
  209. // CHECK:STDOUT: ret void, !dbg !33
  210. // CHECK:STDOUT: }
  211. // CHECK:STDOUT:
  212. // CHECK:STDOUT: declare void @_CFloatArg.Other(float)
  213. // CHECK:STDOUT:
  214. // CHECK:STDOUT: ; Function Attrs: nounwind
  215. // CHECK:STDOUT: define void @_CFloatArg__carbon_thunk.Other(ptr %_) #2 !dbg !34 {
  216. // CHECK:STDOUT: entry:
  217. // CHECK:STDOUT: %.1 = load float, ptr %_, align 4, !dbg !37
  218. // CHECK:STDOUT: call void @_CFloatArg.Other(float %.1), !dbg !37
  219. // CHECK:STDOUT: ret void, !dbg !37
  220. // CHECK:STDOUT: }
  221. // CHECK:STDOUT:
  222. // CHECK:STDOUT: declare i32 @_CIntReturn.Other()
  223. // CHECK:STDOUT:
  224. // CHECK:STDOUT: ; Function Attrs: nounwind
  225. // CHECK:STDOUT: define void @_CIntReturn__carbon_thunk.Other(ptr %_) #2 !dbg !38 {
  226. // CHECK:STDOUT: entry:
  227. // CHECK:STDOUT: %IntReturn.call = call i32 @_CIntReturn.Other(), !dbg !41
  228. // CHECK:STDOUT: store i32 %IntReturn.call, ptr %_, align 4, !dbg !41
  229. // CHECK:STDOUT: ret void, !dbg !41
  230. // CHECK:STDOUT: }
  231. // CHECK:STDOUT:
  232. // CHECK:STDOUT: attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
  233. // CHECK:STDOUT: attributes #1 = { alwaysinline mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
  234. // CHECK:STDOUT: attributes #2 = { nounwind }
  235. // CHECK:STDOUT:
  236. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1, !2, !3, !4}
  237. // CHECK:STDOUT: !llvm.dbg.cu = !{!5}
  238. // CHECK:STDOUT: !llvm.errno.tbaa = !{!7}
  239. // CHECK:STDOUT:
  240. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  241. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  242. // CHECK:STDOUT: !2 = !{i32 8, !"PIC Level", i32 2}
  243. // CHECK:STDOUT: !3 = !{i32 7, !"PIE Level", i32 2}
  244. // CHECK:STDOUT: !4 = !{i32 7, !"uwtable", i32 2}
  245. // CHECK:STDOUT: !5 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !6, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  246. // CHECK:STDOUT: !6 = !DIFile(filename: "function.carbon", directory: "")
  247. // CHECK:STDOUT: !7 = !{!8, !8, i64 0}
  248. // CHECK:STDOUT: !8 = !{!"int", !9, i64 0}
  249. // CHECK:STDOUT: !9 = !{!"omnipotent char", !10, i64 0}
  250. // CHECK:STDOUT: !10 = !{!"Simple C++ TBAA"}
  251. // CHECK:STDOUT: !11 = !{!12, !12, i64 0}
  252. // CHECK:STDOUT: !12 = !{!"bool", !9, i64 0}
  253. // CHECK:STDOUT: !13 = !{!14, !14, i64 0}
  254. // CHECK:STDOUT: !14 = !{!"float", !9, i64 0}
  255. // CHECK:STDOUT: !15 = distinct !DISubprogram(name: "NoArgs__carbon_thunk", linkageName: "_CNoArgs__carbon_thunk.Other", scope: null, file: !16, line: 2, type: !17, spFlags: DISPFlagDefinition, unit: !5)
  256. // CHECK:STDOUT: !16 = !DIFile(filename: "other.carbon", directory: "")
  257. // CHECK:STDOUT: !17 = !DISubroutineType(types: !18)
  258. // CHECK:STDOUT: !18 = !{null}
  259. // CHECK:STDOUT: !19 = !DILocation(line: 2, column: 1, scope: !15)
  260. // CHECK:STDOUT: !20 = distinct !DISubprogram(name: "BoolArg__carbon_thunk", linkageName: "_CBoolArg__carbon_thunk.Other", scope: null, file: !16, line: 3, type: !21, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !24)
  261. // CHECK:STDOUT: !21 = !DISubroutineType(types: !22)
  262. // CHECK:STDOUT: !22 = !{null, !23}
  263. // CHECK:STDOUT: !23 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
  264. // CHECK:STDOUT: !24 = !{!25}
  265. // CHECK:STDOUT: !25 = !DILocalVariable(arg: 1, scope: !20, type: !23)
  266. // CHECK:STDOUT: !26 = !DILocation(line: 3, column: 1, scope: !20)
  267. // CHECK:STDOUT: !27 = distinct !DISubprogram(name: "IntArg__carbon_thunk", linkageName: "_CIntArg__carbon_thunk.Other", scope: null, file: !16, line: 6, type: !28, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !31)
  268. // CHECK:STDOUT: !28 = !DISubroutineType(types: !29)
  269. // CHECK:STDOUT: !29 = !{null, !30}
  270. // CHECK:STDOUT: !30 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
  271. // CHECK:STDOUT: !31 = !{!32}
  272. // CHECK:STDOUT: !32 = !DILocalVariable(arg: 1, scope: !27, type: !30)
  273. // CHECK:STDOUT: !33 = !DILocation(line: 6, column: 1, scope: !27)
  274. // CHECK:STDOUT: !34 = distinct !DISubprogram(name: "FloatArg__carbon_thunk", linkageName: "_CFloatArg__carbon_thunk.Other", scope: null, file: !16, line: 9, type: !21, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !35)
  275. // CHECK:STDOUT: !35 = !{!36}
  276. // CHECK:STDOUT: !36 = !DILocalVariable(arg: 1, scope: !34, type: !23)
  277. // CHECK:STDOUT: !37 = !DILocation(line: 9, column: 1, scope: !34)
  278. // CHECK:STDOUT: !38 = distinct !DISubprogram(name: "IntReturn__carbon_thunk", linkageName: "_CIntReturn__carbon_thunk.Other", scope: null, file: !16, line: 12, type: !28, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !39)
  279. // CHECK:STDOUT: !39 = !{!40}
  280. // CHECK:STDOUT: !40 = !DILocalVariable(arg: 1, scope: !38, type: !30)
  281. // CHECK:STDOUT: !41 = !DILocation(line: 12, column: 1, scope: !38)
  282. // CHECK:STDOUT: ; ModuleID = 'single_file.carbon'
  283. // CHECK:STDOUT: source_filename = "single_file.carbon"
  284. // CHECK:STDOUT: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
  285. // CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu"
  286. // CHECK:STDOUT:
  287. // CHECK:STDOUT: $_Z2G2v = comdat any
  288. // CHECK:STDOUT:
  289. // CHECK:STDOUT: $_Z2G1v = comdat any
  290. // CHECK:STDOUT:
  291. // CHECK:STDOUT: ; Function Attrs: nounwind
  292. // CHECK:STDOUT: define void @_CF.Main() #0 !dbg !11 {
  293. // CHECK:STDOUT: entry:
  294. // CHECK:STDOUT: ret void, !dbg !14
  295. // CHECK:STDOUT: }
  296. // CHECK:STDOUT:
  297. // CHECK:STDOUT: ; Function Attrs: nounwind
  298. // CHECK:STDOUT: define void @_CF__carbon_thunk.Main() #0 !dbg !15 {
  299. // CHECK:STDOUT: entry:
  300. // CHECK:STDOUT: call void @_CF.Main(), !dbg !16
  301. // CHECK:STDOUT: ret void, !dbg !16
  302. // CHECK:STDOUT: }
  303. // CHECK:STDOUT:
  304. // CHECK:STDOUT: ; Function Attrs: nounwind
  305. // CHECK:STDOUT: define void @_CH.Main() #0 !dbg !17 {
  306. // CHECK:STDOUT: entry:
  307. // CHECK:STDOUT: call void @_Z2G2v(), !dbg !18
  308. // CHECK:STDOUT: ret void, !dbg !19
  309. // CHECK:STDOUT: }
  310. // CHECK:STDOUT:
  311. // CHECK:STDOUT: ; Function Attrs: inlinehint mustprogress uwtable
  312. // CHECK:STDOUT: define linkonce_odr dso_local void @_Z2G2v() #1 comdat {
  313. // CHECK:STDOUT: entry:
  314. // CHECK:STDOUT: call void @_Z2G1v()
  315. // CHECK:STDOUT: ret void
  316. // CHECK:STDOUT: }
  317. // CHECK:STDOUT:
  318. // CHECK:STDOUT: ; Function Attrs: inlinehint mustprogress uwtable
  319. // CHECK:STDOUT: define linkonce_odr dso_local void @_Z2G1v() #1 comdat {
  320. // CHECK:STDOUT: entry:
  321. // CHECK:STDOUT: call void @_ZN6CarbonL1FEv()
  322. // CHECK:STDOUT: ret void
  323. // CHECK:STDOUT: }
  324. // CHECK:STDOUT:
  325. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress nounwind uwtable
  326. // CHECK:STDOUT: define internal void @_ZN6CarbonL1FEv() #2 {
  327. // CHECK:STDOUT: entry:
  328. // CHECK:STDOUT: call void @_CF__carbon_thunk.Main()
  329. // CHECK:STDOUT: ret void
  330. // CHECK:STDOUT: }
  331. // CHECK:STDOUT:
  332. // CHECK:STDOUT: attributes #0 = { nounwind }
  333. // CHECK:STDOUT: attributes #1 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
  334. // CHECK:STDOUT: attributes #2 = { alwaysinline mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
  335. // CHECK:STDOUT:
  336. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1, !2, !3, !4}
  337. // CHECK:STDOUT: !llvm.dbg.cu = !{!5}
  338. // CHECK:STDOUT: !llvm.errno.tbaa = !{!7}
  339. // CHECK:STDOUT:
  340. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  341. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  342. // CHECK:STDOUT: !2 = !{i32 8, !"PIC Level", i32 2}
  343. // CHECK:STDOUT: !3 = !{i32 7, !"PIE Level", i32 2}
  344. // CHECK:STDOUT: !4 = !{i32 7, !"uwtable", i32 2}
  345. // CHECK:STDOUT: !5 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !6, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  346. // CHECK:STDOUT: !6 = !DIFile(filename: "single_file.carbon", directory: "")
  347. // CHECK:STDOUT: !7 = !{!8, !8, i64 0}
  348. // CHECK:STDOUT: !8 = !{!"int", !9, i64 0}
  349. // CHECK:STDOUT: !9 = !{!"omnipotent char", !10, i64 0}
  350. // CHECK:STDOUT: !10 = !{!"Simple C++ TBAA"}
  351. // CHECK:STDOUT: !11 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main", scope: null, file: !6, line: 6, type: !12, spFlags: DISPFlagDefinition, unit: !5)
  352. // CHECK:STDOUT: !12 = !DISubroutineType(types: !13)
  353. // CHECK:STDOUT: !13 = !{null}
  354. // CHECK:STDOUT: !14 = !DILocation(line: 6, column: 1, scope: !11)
  355. // CHECK:STDOUT: !15 = distinct !DISubprogram(name: "F__carbon_thunk", linkageName: "_CF__carbon_thunk.Main", scope: null, file: !6, line: 6, type: !12, spFlags: DISPFlagDefinition, unit: !5)
  356. // CHECK:STDOUT: !16 = !DILocation(line: 6, column: 1, scope: !15)
  357. // CHECK:STDOUT: !17 = distinct !DISubprogram(name: "H", linkageName: "_CH.Main", scope: null, file: !6, line: 20, type: !12, spFlags: DISPFlagDefinition, unit: !5)
  358. // CHECK:STDOUT: !18 = !DILocation(line: 20, column: 10, scope: !17)
  359. // CHECK:STDOUT: !19 = !DILocation(line: 20, column: 1, scope: !17)