class_with_fun.carbon 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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/global/class_with_fun.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/global/class_with_fun.carbon
  12. class A {}
  13. fn ret_a() -> A {
  14. return {};
  15. }
  16. var a: A = {};
  17. // CHECK:STDOUT: ; ModuleID = 'class_with_fun.carbon'
  18. // CHECK:STDOUT: source_filename = "class_with_fun.carbon"
  19. // CHECK:STDOUT:
  20. // CHECK:STDOUT: @_Ca.Main = global {} zeroinitializer
  21. // CHECK:STDOUT: @A.val.loc15_12 = internal constant {} zeroinitializer
  22. // CHECK:STDOUT: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 0, ptr @_C__global_init.Main, ptr null }]
  23. // CHECK:STDOUT:
  24. // CHECK:STDOUT: ; Function Attrs: nounwind
  25. // CHECK:STDOUT: define void @_Cret_a.Main(ptr sret({}) %return) #0 !dbg !4 {
  26. // CHECK:STDOUT: entry:
  27. // CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 %return, ptr align 1 @A.val.loc15_12, i64 0, i1 false), !dbg !8
  28. // CHECK:STDOUT: ret void, !dbg !8
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT:
  31. // CHECK:STDOUT: ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
  32. // CHECK:STDOUT: declare void @llvm.memcpy.p0.p0.i64(ptr noalias writeonly captures(none), ptr noalias readonly captures(none), i64, i1 immarg) #1
  33. // CHECK:STDOUT:
  34. // CHECK:STDOUT: ; Function Attrs: nounwind
  35. // CHECK:STDOUT: define internal void @_C__global_init.Main() #0 !dbg !9 {
  36. // CHECK:STDOUT: entry:
  37. // CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 @_Ca.Main, ptr align 1 @A.val.loc15_12, i64 0, i1 false), !dbg !12
  38. // CHECK:STDOUT: ret void, !dbg !13
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: attributes #0 = { nounwind }
  42. // CHECK:STDOUT: attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
  45. // CHECK:STDOUT: !llvm.dbg.cu = !{!2}
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  48. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  49. // CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  50. // CHECK:STDOUT: !3 = !DIFile(filename: "class_with_fun.carbon", directory: "")
  51. // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "ret_a", linkageName: "_Cret_a.Main", scope: null, file: !3, line: 14, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  52. // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
  53. // CHECK:STDOUT: !6 = !{!7}
  54. // CHECK:STDOUT: !7 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 8)
  55. // CHECK:STDOUT: !8 = !DILocation(line: 15, column: 3, scope: !4)
  56. // CHECK:STDOUT: !9 = distinct !DISubprogram(name: "__global_init", linkageName: "_C__global_init.Main", scope: null, file: !3, type: !10, spFlags: DISPFlagDefinition, unit: !2)
  57. // CHECK:STDOUT: !10 = !DISubroutineType(types: !11)
  58. // CHECK:STDOUT: !11 = !{null}
  59. // CHECK:STDOUT: !12 = !DILocation(line: 18, column: 1, scope: !9)
  60. // CHECK:STDOUT: !13 = !DILocation(line: 0, scope: !9)