class_with_fun.carbon 3.2 KB

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