one_entry.carbon 5.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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/struct/one_entry.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/struct/one_entry.carbon
  12. fn Run() -> i32 {
  13. var x: {.a: i32} = {.a = 4};
  14. var _: {.a: i32} = x;
  15. return 0;
  16. }
  17. // CHECK:STDOUT: ; ModuleID = 'one_entry.carbon'
  18. // CHECK:STDOUT: source_filename = "one_entry.carbon"
  19. // CHECK:STDOUT:
  20. // CHECK:STDOUT: ; Function Attrs: nounwind
  21. // CHECK:STDOUT: define i32 @main() #0 !dbg !4 {
  22. // CHECK:STDOUT: entry:
  23. // CHECK:STDOUT: %x.var = alloca { i32 }, align 8, !dbg !8
  24. // CHECK:STDOUT: %_.var = alloca { i32 }, align 8, !dbg !9
  25. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %x.var), !dbg !8
  26. // CHECK:STDOUT: store { i32 } { i32 4 }, ptr %x.var, align 4, !dbg !8
  27. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %_.var), !dbg !9
  28. // CHECK:STDOUT: %.loc15_22.1.a = getelementptr inbounds nuw { i32 }, ptr %x.var, i32 0, i32 0, !dbg !10
  29. // CHECK:STDOUT: %.loc15_22.2 = load i32, ptr %.loc15_22.1.a, align 4, !dbg !10
  30. // CHECK:STDOUT: %.loc15_22.3.struct.init = insertvalue { i32 } poison, i32 %.loc15_22.2, 0, !dbg !10
  31. // CHECK:STDOUT: store { i32 } %.loc15_22.3.struct.init, ptr %_.var, align 4, !dbg !9
  32. // CHECK:STDOUT: call void @"_COp.2595c2fa6d16d130:core.Destroy.Core"(ptr %_.var), !dbg !9
  33. // CHECK:STDOUT: call void @"_COp.2595c2fa6d16d130:core.Destroy.Core"(ptr %x.var), !dbg !8
  34. // CHECK:STDOUT: ret i32 0, !dbg !11
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT:
  37. // CHECK:STDOUT: ; Function Attrs: nounwind
  38. // CHECK:STDOUT: define weak_odr void @"_COp.7e389eab4a7e5487:core.Destroy.Core"(ptr %self) #0 !dbg !12 {
  39. // CHECK:STDOUT: entry:
  40. // CHECK:STDOUT: ret void, !dbg !17
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT:
  43. // CHECK:STDOUT: ; Function Attrs: nounwind
  44. // CHECK:STDOUT: define weak_odr void @"_COp.2595c2fa6d16d130:core.Destroy.Core"(ptr %self) #0 !dbg !18 {
  45. // CHECK:STDOUT: entry:
  46. // CHECK:STDOUT: ret void, !dbg !24
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
  50. // CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #1
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: ; uselistorder directives
  53. // CHECK:STDOUT: uselistorder ptr @"_COp.2595c2fa6d16d130:core.Destroy.Core", { 1, 0 }
  54. // CHECK:STDOUT: uselistorder ptr @llvm.lifetime.start.p0, { 1, 0 }
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: attributes #0 = { nounwind }
  57. // CHECK:STDOUT: attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
  60. // CHECK:STDOUT: !llvm.dbg.cu = !{!2}
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  63. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  64. // CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  65. // CHECK:STDOUT: !3 = !DIFile(filename: "one_entry.carbon", directory: "")
  66. // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Run", linkageName: "main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  67. // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
  68. // CHECK:STDOUT: !6 = !{!7}
  69. // CHECK:STDOUT: !7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
  70. // CHECK:STDOUT: !8 = !DILocation(line: 14, column: 3, scope: !4)
  71. // CHECK:STDOUT: !9 = !DILocation(line: 15, column: 3, scope: !4)
  72. // CHECK:STDOUT: !10 = !DILocation(line: 15, column: 22, scope: !4)
  73. // CHECK:STDOUT: !11 = !DILocation(line: 16, column: 3, scope: !4)
  74. // CHECK:STDOUT: !12 = distinct !DISubprogram(name: "Op", linkageName: "_COp.7e389eab4a7e5487:core.Destroy.Core", scope: null, file: !3, line: 15, type: !13, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !15)
  75. // CHECK:STDOUT: !13 = !DISubroutineType(types: !14)
  76. // CHECK:STDOUT: !14 = !{null, !7}
  77. // CHECK:STDOUT: !15 = !{!16}
  78. // CHECK:STDOUT: !16 = !DILocalVariable(arg: 1, scope: !12, type: !7)
  79. // CHECK:STDOUT: !17 = !DILocation(line: 15, column: 3, scope: !12)
  80. // CHECK:STDOUT: !18 = distinct !DISubprogram(name: "Op", linkageName: "_COp.2595c2fa6d16d130:core.Destroy.Core", scope: null, file: !3, line: 15, type: !19, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !22)
  81. // CHECK:STDOUT: !19 = !DISubroutineType(types: !20)
  82. // CHECK:STDOUT: !20 = !{null, !21}
  83. // CHECK:STDOUT: !21 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
  84. // CHECK:STDOUT: !22 = !{!23}
  85. // CHECK:STDOUT: !23 = !DILocalVariable(arg: 1, scope: !18, type: !21)
  86. // CHECK:STDOUT: !24 = !DILocation(line: 15, column: 3, scope: !18)