function_decl.carbon 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  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/interop/cpp/function_decl.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/interop/cpp/function_decl.carbon
  12. // ============================================================================
  13. // function_decl
  14. // ============================================================================
  15. // --- function_decl.h
  16. void foo();
  17. // --- import_function_decl.carbon
  18. library "[[@TEST_NAME]]";
  19. import Cpp library "function_decl.h";
  20. fn MyF() {
  21. Cpp.foo();
  22. }
  23. // ============================================================================
  24. // inline_function_decl
  25. // ============================================================================
  26. // --- inline_function_decl.h
  27. inline void foo() {}
  28. // --- import_inline_function_decl.carbon
  29. library "[[@TEST_NAME]]";
  30. import Cpp library "inline_function_decl.h";
  31. fn MyF() {
  32. Cpp.foo();
  33. }
  34. // ============================================================================
  35. // inline_used_function_decl
  36. // ============================================================================
  37. // --- inline_used_function_decl.h
  38. inline __attribute__((used)) void foo() {}
  39. // --- import_inline_used_function_decl.carbon
  40. library "[[@TEST_NAME]]";
  41. import Cpp library "inline_used_function_decl.h";
  42. fn MyF() {
  43. Cpp.foo();
  44. }
  45. // ============================================================================
  46. // multiple_inline_function_decls
  47. // ============================================================================
  48. // --- multiple_inline_function_decls.h
  49. inline void foo1() {}
  50. inline void foo2() {}
  51. inline void foo3() {}
  52. // --- import_multiple_inline_function_decls.carbon
  53. library "[[@TEST_NAME]]";
  54. import Cpp library "multiple_inline_function_decls.h";
  55. fn MyF() {
  56. Cpp.foo1();
  57. Cpp.foo2();
  58. Cpp.foo3();
  59. }
  60. // ============================================================================
  61. // inline_recursive_function_decl
  62. // ============================================================================
  63. // --- inline_recursive_function_decl.h
  64. inline void foo1() {}
  65. inline void foo2() { foo1(); }
  66. // --- import_inline_recursive_function_decl.carbon
  67. library "[[@TEST_NAME]]";
  68. import Cpp library "inline_recursive_function_decl.h";
  69. fn MyF() {
  70. // This should generate the definition of the inline function `foo1()`.
  71. Cpp.foo2();
  72. }
  73. // ============================================================================
  74. // Default arguments
  75. // ============================================================================
  76. // --- with_default_args.h
  77. void NoReturnValue(int a = 1, int b = 2);
  78. int SimpleReturnValue(int a = 1, int b = 2);
  79. // --- call_with_default_args.carbon
  80. library "[[@TEST_NAME]]";
  81. import Cpp library "with_default_args.h";
  82. fn MyF() -> i32 {
  83. Cpp.NoReturnValue();
  84. Cpp.NoReturnValue(3);
  85. Cpp.NoReturnValue(3, 4);
  86. var value: i32 = Cpp.SimpleReturnValue();
  87. value = Cpp.SimpleReturnValue(3);
  88. value = Cpp.SimpleReturnValue(3, 4);
  89. return value;
  90. }
  91. // CHECK:STDOUT: ; ModuleID = 'import_function_decl.carbon'
  92. // CHECK:STDOUT: source_filename = "import_function_decl.carbon"
  93. // 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"
  94. // CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu"
  95. // CHECK:STDOUT:
  96. // CHECK:STDOUT: ; Function Attrs: nounwind
  97. // CHECK:STDOUT: define void @_CMyF.Main() #0 !dbg !11 {
  98. // CHECK:STDOUT: entry:
  99. // CHECK:STDOUT: call void @_Z3foov(), !dbg !14
  100. // CHECK:STDOUT: ret void, !dbg !15
  101. // CHECK:STDOUT: }
  102. // CHECK:STDOUT:
  103. // CHECK:STDOUT: declare void @_Z3foov() #1
  104. // CHECK:STDOUT:
  105. // CHECK:STDOUT: attributes #0 = { nounwind }
  106. // CHECK:STDOUT: attributes #1 = { "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" }
  107. // CHECK:STDOUT:
  108. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1, !2, !3, !4}
  109. // CHECK:STDOUT: !llvm.dbg.cu = !{!5}
  110. // CHECK:STDOUT: !llvm.errno.tbaa = !{!7}
  111. // CHECK:STDOUT:
  112. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  113. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  114. // CHECK:STDOUT: !2 = !{i32 8, !"PIC Level", i32 2}
  115. // CHECK:STDOUT: !3 = !{i32 7, !"PIE Level", i32 2}
  116. // CHECK:STDOUT: !4 = !{i32 7, !"uwtable", i32 2}
  117. // CHECK:STDOUT: !5 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !6, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  118. // CHECK:STDOUT: !6 = !DIFile(filename: "import_function_decl.carbon", directory: "")
  119. // CHECK:STDOUT: !7 = !{!8, !8, i64 0}
  120. // CHECK:STDOUT: !8 = !{!"int", !9, i64 0}
  121. // CHECK:STDOUT: !9 = !{!"omnipotent char", !10, i64 0}
  122. // CHECK:STDOUT: !10 = !{!"Simple C++ TBAA"}
  123. // CHECK:STDOUT: !11 = distinct !DISubprogram(name: "MyF", linkageName: "_CMyF.Main", scope: null, file: !6, line: 6, type: !12, spFlags: DISPFlagDefinition, unit: !5)
  124. // CHECK:STDOUT: !12 = !DISubroutineType(types: !13)
  125. // CHECK:STDOUT: !13 = !{null}
  126. // CHECK:STDOUT: !14 = !DILocation(line: 7, column: 3, scope: !11)
  127. // CHECK:STDOUT: !15 = !DILocation(line: 6, column: 1, scope: !11)
  128. // CHECK:STDOUT: ; ModuleID = 'import_inline_function_decl.carbon'
  129. // CHECK:STDOUT: source_filename = "import_inline_function_decl.carbon"
  130. // 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"
  131. // CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu"
  132. // CHECK:STDOUT:
  133. // CHECK:STDOUT: $_Z3foov = comdat any
  134. // CHECK:STDOUT:
  135. // CHECK:STDOUT: ; Function Attrs: nounwind
  136. // CHECK:STDOUT: define void @_CMyF.Main() #0 !dbg !11 {
  137. // CHECK:STDOUT: entry:
  138. // CHECK:STDOUT: call void @_Z3foov(), !dbg !14
  139. // CHECK:STDOUT: ret void, !dbg !15
  140. // CHECK:STDOUT: }
  141. // CHECK:STDOUT:
  142. // CHECK:STDOUT: ; Function Attrs: inlinehint mustprogress nounwind uwtable
  143. // CHECK:STDOUT: define linkonce_odr dso_local void @_Z3foov() #1 comdat {
  144. // CHECK:STDOUT: entry:
  145. // CHECK:STDOUT: ret void
  146. // CHECK:STDOUT: }
  147. // CHECK:STDOUT:
  148. // CHECK:STDOUT: attributes #0 = { nounwind }
  149. // CHECK:STDOUT: attributes #1 = { inlinehint 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" }
  150. // CHECK:STDOUT:
  151. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1, !2, !3, !4}
  152. // CHECK:STDOUT: !llvm.dbg.cu = !{!5}
  153. // CHECK:STDOUT: !llvm.errno.tbaa = !{!7}
  154. // CHECK:STDOUT:
  155. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  156. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  157. // CHECK:STDOUT: !2 = !{i32 8, !"PIC Level", i32 2}
  158. // CHECK:STDOUT: !3 = !{i32 7, !"PIE Level", i32 2}
  159. // CHECK:STDOUT: !4 = !{i32 7, !"uwtable", i32 2}
  160. // CHECK:STDOUT: !5 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !6, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  161. // CHECK:STDOUT: !6 = !DIFile(filename: "import_inline_function_decl.carbon", directory: "")
  162. // CHECK:STDOUT: !7 = !{!8, !8, i64 0}
  163. // CHECK:STDOUT: !8 = !{!"int", !9, i64 0}
  164. // CHECK:STDOUT: !9 = !{!"omnipotent char", !10, i64 0}
  165. // CHECK:STDOUT: !10 = !{!"Simple C++ TBAA"}
  166. // CHECK:STDOUT: !11 = distinct !DISubprogram(name: "MyF", linkageName: "_CMyF.Main", scope: null, file: !6, line: 6, type: !12, spFlags: DISPFlagDefinition, unit: !5)
  167. // CHECK:STDOUT: !12 = !DISubroutineType(types: !13)
  168. // CHECK:STDOUT: !13 = !{null}
  169. // CHECK:STDOUT: !14 = !DILocation(line: 7, column: 3, scope: !11)
  170. // CHECK:STDOUT: !15 = !DILocation(line: 6, column: 1, scope: !11)
  171. // CHECK:STDOUT: ; ModuleID = 'import_inline_used_function_decl.carbon'
  172. // CHECK:STDOUT: source_filename = "import_inline_used_function_decl.carbon"
  173. // 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"
  174. // CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu"
  175. // CHECK:STDOUT:
  176. // CHECK:STDOUT: $_Z3foov = comdat any
  177. // CHECK:STDOUT:
  178. // CHECK:STDOUT: @llvm.compiler.used = appending global [1 x ptr] [ptr @_Z3foov], section "llvm.metadata"
  179. // CHECK:STDOUT:
  180. // CHECK:STDOUT: ; Function Attrs: inlinehint mustprogress nounwind uwtable
  181. // CHECK:STDOUT: define linkonce_odr dso_local void @_Z3foov() #0 comdat {
  182. // CHECK:STDOUT: entry:
  183. // CHECK:STDOUT: ret void
  184. // CHECK:STDOUT: }
  185. // CHECK:STDOUT:
  186. // CHECK:STDOUT: ; Function Attrs: nounwind
  187. // CHECK:STDOUT: define void @_CMyF.Main() #1 !dbg !11 {
  188. // CHECK:STDOUT: entry:
  189. // CHECK:STDOUT: call void @_Z3foov(), !dbg !14
  190. // CHECK:STDOUT: ret void, !dbg !15
  191. // CHECK:STDOUT: }
  192. // CHECK:STDOUT:
  193. // CHECK:STDOUT: ; uselistorder directives
  194. // CHECK:STDOUT: uselistorder ptr @_Z3foov, { 1, 0 }
  195. // CHECK:STDOUT:
  196. // CHECK:STDOUT: attributes #0 = { inlinehint 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" }
  197. // CHECK:STDOUT: attributes #1 = { nounwind }
  198. // CHECK:STDOUT:
  199. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1, !2, !3, !4}
  200. // CHECK:STDOUT: !llvm.dbg.cu = !{!5}
  201. // CHECK:STDOUT: !llvm.errno.tbaa = !{!7}
  202. // CHECK:STDOUT:
  203. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  204. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  205. // CHECK:STDOUT: !2 = !{i32 8, !"PIC Level", i32 2}
  206. // CHECK:STDOUT: !3 = !{i32 7, !"PIE Level", i32 2}
  207. // CHECK:STDOUT: !4 = !{i32 7, !"uwtable", i32 2}
  208. // CHECK:STDOUT: !5 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !6, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  209. // CHECK:STDOUT: !6 = !DIFile(filename: "import_inline_used_function_decl.carbon", directory: "")
  210. // CHECK:STDOUT: !7 = !{!8, !8, i64 0}
  211. // CHECK:STDOUT: !8 = !{!"int", !9, i64 0}
  212. // CHECK:STDOUT: !9 = !{!"omnipotent char", !10, i64 0}
  213. // CHECK:STDOUT: !10 = !{!"Simple C++ TBAA"}
  214. // CHECK:STDOUT: !11 = distinct !DISubprogram(name: "MyF", linkageName: "_CMyF.Main", scope: null, file: !6, line: 6, type: !12, spFlags: DISPFlagDefinition, unit: !5)
  215. // CHECK:STDOUT: !12 = !DISubroutineType(types: !13)
  216. // CHECK:STDOUT: !13 = !{null}
  217. // CHECK:STDOUT: !14 = !DILocation(line: 7, column: 3, scope: !11)
  218. // CHECK:STDOUT: !15 = !DILocation(line: 6, column: 1, scope: !11)
  219. // CHECK:STDOUT: ; ModuleID = 'import_multiple_inline_function_decls.carbon'
  220. // CHECK:STDOUT: source_filename = "import_multiple_inline_function_decls.carbon"
  221. // 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"
  222. // CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu"
  223. // CHECK:STDOUT:
  224. // CHECK:STDOUT: $_Z4foo1v = comdat any
  225. // CHECK:STDOUT:
  226. // CHECK:STDOUT: $_Z4foo2v = comdat any
  227. // CHECK:STDOUT:
  228. // CHECK:STDOUT: $_Z4foo3v = comdat any
  229. // CHECK:STDOUT:
  230. // CHECK:STDOUT: ; Function Attrs: nounwind
  231. // CHECK:STDOUT: define void @_CMyF.Main() #0 !dbg !11 {
  232. // CHECK:STDOUT: entry:
  233. // CHECK:STDOUT: call void @_Z4foo1v(), !dbg !14
  234. // CHECK:STDOUT: call void @_Z4foo2v(), !dbg !15
  235. // CHECK:STDOUT: call void @_Z4foo3v(), !dbg !16
  236. // CHECK:STDOUT: ret void, !dbg !17
  237. // CHECK:STDOUT: }
  238. // CHECK:STDOUT:
  239. // CHECK:STDOUT: ; Function Attrs: inlinehint mustprogress nounwind uwtable
  240. // CHECK:STDOUT: define linkonce_odr dso_local void @_Z4foo1v() #1 comdat {
  241. // CHECK:STDOUT: entry:
  242. // CHECK:STDOUT: ret void
  243. // CHECK:STDOUT: }
  244. // CHECK:STDOUT:
  245. // CHECK:STDOUT: ; Function Attrs: inlinehint mustprogress nounwind uwtable
  246. // CHECK:STDOUT: define linkonce_odr dso_local void @_Z4foo2v() #1 comdat {
  247. // CHECK:STDOUT: entry:
  248. // CHECK:STDOUT: ret void
  249. // CHECK:STDOUT: }
  250. // CHECK:STDOUT:
  251. // CHECK:STDOUT: ; Function Attrs: inlinehint mustprogress nounwind uwtable
  252. // CHECK:STDOUT: define linkonce_odr dso_local void @_Z4foo3v() #1 comdat {
  253. // CHECK:STDOUT: entry:
  254. // CHECK:STDOUT: ret void
  255. // CHECK:STDOUT: }
  256. // CHECK:STDOUT:
  257. // CHECK:STDOUT: attributes #0 = { nounwind }
  258. // CHECK:STDOUT: attributes #1 = { inlinehint 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" }
  259. // CHECK:STDOUT:
  260. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1, !2, !3, !4}
  261. // CHECK:STDOUT: !llvm.dbg.cu = !{!5}
  262. // CHECK:STDOUT: !llvm.errno.tbaa = !{!7}
  263. // CHECK:STDOUT:
  264. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  265. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  266. // CHECK:STDOUT: !2 = !{i32 8, !"PIC Level", i32 2}
  267. // CHECK:STDOUT: !3 = !{i32 7, !"PIE Level", i32 2}
  268. // CHECK:STDOUT: !4 = !{i32 7, !"uwtable", i32 2}
  269. // CHECK:STDOUT: !5 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !6, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  270. // CHECK:STDOUT: !6 = !DIFile(filename: "import_multiple_inline_function_decls.carbon", directory: "")
  271. // CHECK:STDOUT: !7 = !{!8, !8, i64 0}
  272. // CHECK:STDOUT: !8 = !{!"int", !9, i64 0}
  273. // CHECK:STDOUT: !9 = !{!"omnipotent char", !10, i64 0}
  274. // CHECK:STDOUT: !10 = !{!"Simple C++ TBAA"}
  275. // CHECK:STDOUT: !11 = distinct !DISubprogram(name: "MyF", linkageName: "_CMyF.Main", scope: null, file: !6, line: 6, type: !12, spFlags: DISPFlagDefinition, unit: !5)
  276. // CHECK:STDOUT: !12 = !DISubroutineType(types: !13)
  277. // CHECK:STDOUT: !13 = !{null}
  278. // CHECK:STDOUT: !14 = !DILocation(line: 7, column: 3, scope: !11)
  279. // CHECK:STDOUT: !15 = !DILocation(line: 8, column: 3, scope: !11)
  280. // CHECK:STDOUT: !16 = !DILocation(line: 9, column: 3, scope: !11)
  281. // CHECK:STDOUT: !17 = !DILocation(line: 6, column: 1, scope: !11)
  282. // CHECK:STDOUT: ; ModuleID = 'import_inline_recursive_function_decl.carbon'
  283. // CHECK:STDOUT: source_filename = "import_inline_recursive_function_decl.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: $_Z4foo2v = comdat any
  288. // CHECK:STDOUT:
  289. // CHECK:STDOUT: $_Z4foo1v = comdat any
  290. // CHECK:STDOUT:
  291. // CHECK:STDOUT: ; Function Attrs: nounwind
  292. // CHECK:STDOUT: define void @_CMyF.Main() #0 !dbg !11 {
  293. // CHECK:STDOUT: entry:
  294. // CHECK:STDOUT: call void @_Z4foo2v(), !dbg !14
  295. // CHECK:STDOUT: ret void, !dbg !15
  296. // CHECK:STDOUT: }
  297. // CHECK:STDOUT:
  298. // CHECK:STDOUT: ; Function Attrs: inlinehint mustprogress uwtable
  299. // CHECK:STDOUT: define linkonce_odr dso_local void @_Z4foo2v() #1 comdat {
  300. // CHECK:STDOUT: entry:
  301. // CHECK:STDOUT: call void @_Z4foo1v()
  302. // CHECK:STDOUT: ret void
  303. // CHECK:STDOUT: }
  304. // CHECK:STDOUT:
  305. // CHECK:STDOUT: ; Function Attrs: inlinehint mustprogress nounwind uwtable
  306. // CHECK:STDOUT: define linkonce_odr dso_local void @_Z4foo1v() #2 comdat {
  307. // CHECK:STDOUT: entry:
  308. // CHECK:STDOUT: ret void
  309. // CHECK:STDOUT: }
  310. // CHECK:STDOUT:
  311. // CHECK:STDOUT: attributes #0 = { nounwind }
  312. // 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" }
  313. // CHECK:STDOUT: attributes #2 = { inlinehint 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" }
  314. // CHECK:STDOUT:
  315. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1, !2, !3, !4}
  316. // CHECK:STDOUT: !llvm.dbg.cu = !{!5}
  317. // CHECK:STDOUT: !llvm.errno.tbaa = !{!7}
  318. // CHECK:STDOUT:
  319. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  320. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  321. // CHECK:STDOUT: !2 = !{i32 8, !"PIC Level", i32 2}
  322. // CHECK:STDOUT: !3 = !{i32 7, !"PIE Level", i32 2}
  323. // CHECK:STDOUT: !4 = !{i32 7, !"uwtable", i32 2}
  324. // CHECK:STDOUT: !5 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !6, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  325. // CHECK:STDOUT: !6 = !DIFile(filename: "import_inline_recursive_function_decl.carbon", directory: "")
  326. // CHECK:STDOUT: !7 = !{!8, !8, i64 0}
  327. // CHECK:STDOUT: !8 = !{!"int", !9, i64 0}
  328. // CHECK:STDOUT: !9 = !{!"omnipotent char", !10, i64 0}
  329. // CHECK:STDOUT: !10 = !{!"Simple C++ TBAA"}
  330. // CHECK:STDOUT: !11 = distinct !DISubprogram(name: "MyF", linkageName: "_CMyF.Main", scope: null, file: !6, line: 6, type: !12, spFlags: DISPFlagDefinition, unit: !5)
  331. // CHECK:STDOUT: !12 = !DISubroutineType(types: !13)
  332. // CHECK:STDOUT: !13 = !{null}
  333. // CHECK:STDOUT: !14 = !DILocation(line: 8, column: 3, scope: !11)
  334. // CHECK:STDOUT: !15 = !DILocation(line: 6, column: 1, scope: !11)
  335. // CHECK:STDOUT: ; ModuleID = 'call_with_default_args.carbon'
  336. // CHECK:STDOUT: source_filename = "call_with_default_args.carbon"
  337. // 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"
  338. // CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu"
  339. // CHECK:STDOUT:
  340. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable
  341. // CHECK:STDOUT: define dso_local void @_Z13NoReturnValueii.carbon_thunk0() #0 {
  342. // CHECK:STDOUT: entry:
  343. // CHECK:STDOUT: call void @_Z13NoReturnValueii(i32 noundef 1, i32 noundef 2)
  344. // CHECK:STDOUT: ret void
  345. // CHECK:STDOUT: }
  346. // CHECK:STDOUT:
  347. // CHECK:STDOUT: declare void @_Z13NoReturnValueii(i32 noundef, i32 noundef) #1
  348. // CHECK:STDOUT:
  349. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable
  350. // CHECK:STDOUT: define dso_local void @_Z13NoReturnValueii.carbon_thunk1(i32 noundef %a) #0 {
  351. // CHECK:STDOUT: entry:
  352. // CHECK:STDOUT: %a.addr = alloca i32, align 4
  353. // CHECK:STDOUT: store i32 %a, ptr %a.addr, align 4, !tbaa !7
  354. // CHECK:STDOUT: %0 = load i32, ptr %a.addr, align 4, !tbaa !7
  355. // CHECK:STDOUT: call void @_Z13NoReturnValueii(i32 noundef %0, i32 noundef 2)
  356. // CHECK:STDOUT: ret void
  357. // CHECK:STDOUT: }
  358. // CHECK:STDOUT:
  359. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable
  360. // CHECK:STDOUT: define dso_local noundef i32 @_Z17SimpleReturnValueii.carbon_thunk0() #0 {
  361. // CHECK:STDOUT: entry:
  362. // CHECK:STDOUT: %call = call noundef i32 @_Z17SimpleReturnValueii(i32 noundef 1, i32 noundef 2)
  363. // CHECK:STDOUT: ret i32 %call
  364. // CHECK:STDOUT: }
  365. // CHECK:STDOUT:
  366. // CHECK:STDOUT: declare noundef i32 @_Z17SimpleReturnValueii(i32 noundef, i32 noundef) #1
  367. // CHECK:STDOUT:
  368. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable
  369. // CHECK:STDOUT: define dso_local noundef i32 @_Z17SimpleReturnValueii.carbon_thunk1(i32 noundef %a) #0 {
  370. // CHECK:STDOUT: entry:
  371. // CHECK:STDOUT: %a.addr = alloca i32, align 4
  372. // CHECK:STDOUT: store i32 %a, ptr %a.addr, align 4, !tbaa !7
  373. // CHECK:STDOUT: %0 = load i32, ptr %a.addr, align 4, !tbaa !7
  374. // CHECK:STDOUT: %call = call noundef i32 @_Z17SimpleReturnValueii(i32 noundef %0, i32 noundef 2)
  375. // CHECK:STDOUT: ret i32 %call
  376. // CHECK:STDOUT: }
  377. // CHECK:STDOUT:
  378. // CHECK:STDOUT: ; Function Attrs: nounwind
  379. // CHECK:STDOUT: define i32 @_CMyF.Main() #2 !dbg !11 {
  380. // CHECK:STDOUT: entry:
  381. // CHECK:STDOUT: %value.var = alloca i32, align 4, !dbg !15
  382. // CHECK:STDOUT: call void @_Z13NoReturnValueii.carbon_thunk0(), !dbg !16
  383. // CHECK:STDOUT: call void @_Z13NoReturnValueii.carbon_thunk1(i32 3), !dbg !17
  384. // CHECK:STDOUT: call void @_Z13NoReturnValueii(i32 3, i32 4), !dbg !18
  385. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %value.var), !dbg !15
  386. // CHECK:STDOUT: %SimpleReturnValue__carbon_thunk.call.loc11 = call i32 @_Z17SimpleReturnValueii.carbon_thunk0(), !dbg !19
  387. // CHECK:STDOUT: store i32 %SimpleReturnValue__carbon_thunk.call.loc11, ptr %value.var, align 4, !dbg !15
  388. // CHECK:STDOUT: %SimpleReturnValue__carbon_thunk.call.loc12 = call i32 @_Z17SimpleReturnValueii.carbon_thunk1(i32 3), !dbg !20
  389. // CHECK:STDOUT: store i32 %SimpleReturnValue__carbon_thunk.call.loc12, ptr %value.var, align 4, !dbg !21
  390. // CHECK:STDOUT: %SimpleReturnValue.call = call i32 @_Z17SimpleReturnValueii(i32 3, i32 4), !dbg !22
  391. // CHECK:STDOUT: store i32 %SimpleReturnValue.call, ptr %value.var, align 4, !dbg !23
  392. // CHECK:STDOUT: %.loc14 = load i32, ptr %value.var, align 4, !dbg !24
  393. // CHECK:STDOUT: call void @"_COp.7e389eab4a7e5487:core.Destroy.Core"(ptr %value.var), !dbg !15
  394. // CHECK:STDOUT: ret i32 %.loc14, !dbg !25
  395. // CHECK:STDOUT: }
  396. // CHECK:STDOUT:
  397. // CHECK:STDOUT: ; Function Attrs: nounwind
  398. // CHECK:STDOUT: define weak_odr void @"_COp.7e389eab4a7e5487:core.Destroy.Core"(ptr %self) #2 !dbg !26 {
  399. // CHECK:STDOUT: entry:
  400. // CHECK:STDOUT: ret void, !dbg !31
  401. // CHECK:STDOUT: }
  402. // CHECK:STDOUT:
  403. // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
  404. // CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #3
  405. // CHECK:STDOUT:
  406. // CHECK:STDOUT: attributes #0 = { alwaysinline 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" }
  407. // CHECK:STDOUT: attributes #1 = { "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" }
  408. // CHECK:STDOUT: attributes #2 = { nounwind }
  409. // CHECK:STDOUT: attributes #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
  410. // CHECK:STDOUT:
  411. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1, !2, !3, !4}
  412. // CHECK:STDOUT: !llvm.dbg.cu = !{!5}
  413. // CHECK:STDOUT: !llvm.errno.tbaa = !{!7}
  414. // CHECK:STDOUT:
  415. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  416. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  417. // CHECK:STDOUT: !2 = !{i32 8, !"PIC Level", i32 2}
  418. // CHECK:STDOUT: !3 = !{i32 7, !"PIE Level", i32 2}
  419. // CHECK:STDOUT: !4 = !{i32 7, !"uwtable", i32 2}
  420. // CHECK:STDOUT: !5 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !6, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  421. // CHECK:STDOUT: !6 = !DIFile(filename: "call_with_default_args.carbon", directory: "")
  422. // CHECK:STDOUT: !7 = !{!8, !8, i64 0}
  423. // CHECK:STDOUT: !8 = !{!"int", !9, i64 0}
  424. // CHECK:STDOUT: !9 = !{!"omnipotent char", !10, i64 0}
  425. // CHECK:STDOUT: !10 = !{!"Simple C++ TBAA"}
  426. // CHECK:STDOUT: !11 = distinct !DISubprogram(name: "MyF", linkageName: "_CMyF.Main", scope: null, file: !6, line: 6, type: !12, spFlags: DISPFlagDefinition, unit: !5)
  427. // CHECK:STDOUT: !12 = !DISubroutineType(types: !13)
  428. // CHECK:STDOUT: !13 = !{!14}
  429. // CHECK:STDOUT: !14 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
  430. // CHECK:STDOUT: !15 = !DILocation(line: 11, column: 3, scope: !11)
  431. // CHECK:STDOUT: !16 = !DILocation(line: 7, column: 3, scope: !11)
  432. // CHECK:STDOUT: !17 = !DILocation(line: 8, column: 3, scope: !11)
  433. // CHECK:STDOUT: !18 = !DILocation(line: 9, column: 3, scope: !11)
  434. // CHECK:STDOUT: !19 = !DILocation(line: 11, column: 20, scope: !11)
  435. // CHECK:STDOUT: !20 = !DILocation(line: 12, column: 11, scope: !11)
  436. // CHECK:STDOUT: !21 = !DILocation(line: 12, column: 3, scope: !11)
  437. // CHECK:STDOUT: !22 = !DILocation(line: 13, column: 11, scope: !11)
  438. // CHECK:STDOUT: !23 = !DILocation(line: 13, column: 3, scope: !11)
  439. // CHECK:STDOUT: !24 = !DILocation(line: 14, column: 10, scope: !11)
  440. // CHECK:STDOUT: !25 = !DILocation(line: 14, column: 3, scope: !11)
  441. // CHECK:STDOUT: !26 = distinct !DISubprogram(name: "Op", linkageName: "_COp.7e389eab4a7e5487:core.Destroy.Core", scope: null, file: !6, line: 11, type: !27, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !29)
  442. // CHECK:STDOUT: !27 = !DISubroutineType(types: !28)
  443. // CHECK:STDOUT: !28 = !{null, !14}
  444. // CHECK:STDOUT: !29 = !{!30}
  445. // CHECK:STDOUT: !30 = !DILocalVariable(arg: 1, scope: !26, type: !14)
  446. // CHECK:STDOUT: !31 = !DILocation(line: 11, column: 3, scope: !26)