implicit_empty_tuple_as_arg.carbon 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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/convert.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/function/call/implicit_empty_tuple_as_arg.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/function/call/implicit_empty_tuple_as_arg.carbon
  12. fn Foo() {}
  13. fn Bar(a: ()) -> () { return a; }
  14. fn Main() {
  15. var x: () = Bar(Foo());
  16. }
  17. // CHECK:STDOUT: ; ModuleID = 'implicit_empty_tuple_as_arg.carbon'
  18. // CHECK:STDOUT: source_filename = "implicit_empty_tuple_as_arg.carbon"
  19. // CHECK:STDOUT:
  20. // CHECK:STDOUT: define void @_CFoo.Main() !dbg !4 {
  21. // CHECK:STDOUT: entry:
  22. // CHECK:STDOUT: ret void, !dbg !7
  23. // CHECK:STDOUT: }
  24. // CHECK:STDOUT:
  25. // CHECK:STDOUT: define void @_CBar.Main() !dbg !8 {
  26. // CHECK:STDOUT: entry:
  27. // CHECK:STDOUT: ret void, !dbg !9
  28. // CHECK:STDOUT: }
  29. // CHECK:STDOUT:
  30. // CHECK:STDOUT: define void @_CMain.Main() !dbg !10 {
  31. // CHECK:STDOUT: entry:
  32. // CHECK:STDOUT: %x.var = alloca {}, align 8, !dbg !11
  33. // CHECK:STDOUT: %.loc19_23.1.temp = alloca {}, align 8, !dbg !12
  34. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 0, ptr %x.var), !dbg !11
  35. // CHECK:STDOUT: call void @_CFoo.Main(), !dbg !12
  36. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 0, ptr %.loc19_23.1.temp), !dbg !12
  37. // CHECK:STDOUT: call void @_CBar.Main(), !dbg !13
  38. // CHECK:STDOUT: ret void, !dbg !14
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
  42. // CHECK:STDOUT: declare void @llvm.lifetime.start.p0(i64 immarg, ptr captures(none)) #0
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: ; uselistorder directives
  45. // CHECK:STDOUT: uselistorder ptr @llvm.lifetime.start.p0, { 1, 0 }
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
  50. // CHECK:STDOUT: !llvm.dbg.cu = !{!2}
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  53. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  54. // CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  55. // CHECK:STDOUT: !3 = !DIFile(filename: "implicit_empty_tuple_as_arg.carbon", directory: "")
  56. // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Foo", linkageName: "_CFoo.Main", scope: null, file: !3, line: 14, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  57. // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
  58. // CHECK:STDOUT: !6 = !{}
  59. // CHECK:STDOUT: !7 = !DILocation(line: 14, column: 1, scope: !4)
  60. // CHECK:STDOUT: !8 = distinct !DISubprogram(name: "Bar", linkageName: "_CBar.Main", scope: null, file: !3, line: 16, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  61. // CHECK:STDOUT: !9 = !DILocation(line: 16, column: 23, scope: !8)
  62. // CHECK:STDOUT: !10 = distinct !DISubprogram(name: "Main", linkageName: "_CMain.Main", scope: null, file: !3, line: 18, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  63. // CHECK:STDOUT: !11 = !DILocation(line: 19, column: 3, scope: !10)
  64. // CHECK:STDOUT: !12 = !DILocation(line: 19, column: 19, scope: !10)
  65. // CHECK:STDOUT: !13 = !DILocation(line: 19, column: 15, scope: !10)
  66. // CHECK:STDOUT: !14 = !DILocation(line: 18, column: 1, scope: !10)