type-unique-simple-a.ll 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. ; REQUIRES: object-emission
  2. ; RUN: llvm-link %s %p/type-unique-simple-b.ll -S -o %t
  3. ; RUN: cat %t | FileCheck %s -check-prefix=LINK
  4. ; RUN: %llc_dwarf -filetype=obj -O0 < %t > %t2
  5. ; RUN: llvm-dwarfdump -debug-dump=info %t2 | FileCheck %s
  6. ; Make sure the backend generates a single DIE and uses ref_addr.
  7. ; CHECK: 0x[[BASE:.*]]: DW_TAG_structure_type
  8. ; CHECK-NEXT: DW_AT_name {{.*}} = "Base"
  9. ; CHECK-NOT: DW_TAG_structure_type
  10. ; CHECK: 0x[[INT:.*]]: DW_TAG_base_type
  11. ; CHECK-NEXT: DW_AT_name {{.*}} = "int"
  12. ; CHECK-NOT: DW_TAG_base_type
  13. ; CHECK: DW_TAG_compile_unit
  14. ; CHECK: DW_TAG_formal_parameter
  15. ; CHECK: DW_AT_type [DW_FORM_ref_addr] {{.*}}[[INT]])
  16. ; CHECK: DW_TAG_variable
  17. ; CHECK: DW_AT_type [DW_FORM_ref_addr] {{.*}}[[BASE]])
  18. ; Make sure llvm-link only generates a single copy of the struct.
  19. ; LINK: DW_TAG_structure_type
  20. ; LINK-NOT: DW_TAG_structure_type
  21. ; Content of header files:
  22. ; struct Base {
  23. ; int a;
  24. ; };
  25. ; Content of foo.cpp:
  26. ;
  27. ; #include "a.hpp"
  28. ; void f(int a) {
  29. ; Base t;
  30. ; }
  31. ; Content of bar.cpp:
  32. ;
  33. ; #include "a.hpp"
  34. ; void f(int);
  35. ; void g(int a) {
  36. ; Base t;
  37. ; }
  38. ; int main() {
  39. ; f(0);
  40. ; g(1);
  41. ; return 0;
  42. ; }
  43. ; ModuleID = 'foo.cpp'
  44. %struct.Base = type { i32 }
  45. ; Function Attrs: nounwind ssp uwtable
  46. define void @_Z1fi(i32 %a) #0 {
  47. entry:
  48. %a.addr = alloca i32, align 4
  49. %t = alloca %struct.Base, align 4
  50. store i32 %a, i32* %a.addr, align 4
  51. call void @llvm.dbg.declare(metadata i32* %a.addr, metadata !15, metadata !DIExpression()), !dbg !16
  52. call void @llvm.dbg.declare(metadata %struct.Base* %t, metadata !17, metadata !DIExpression()), !dbg !18
  53. ret void, !dbg !19
  54. }
  55. ; Function Attrs: nounwind readnone
  56. declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
  57. attributes #0 = { nounwind ssp uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
  58. attributes #1 = { nounwind readnone }
  59. !llvm.dbg.cu = !{!0}
  60. !llvm.module.flags = !{!14, !20}
  61. !0 = !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.4 (http://llvm.org/git/clang.git c23b1db6268c8e7ce64026d57d1510c1aac200a0) (http://llvm.org/git/llvm.git 09b98fe3978eddefc2145adc1056cf21580ce945)", isOptimized: false, emissionKind: 0, file: !1, enums: !2, retainedTypes: !3, subprograms: !9, globals: !2, imports: !2)
  62. !1 = !DIFile(filename: "foo.cpp", directory: "/Users/mren/c_testing/type_unique_air/simple")
  63. !2 = !{}
  64. !3 = !{!4}
  65. !4 = !DICompositeType(tag: DW_TAG_structure_type, name: "Base", line: 1, size: 32, align: 32, file: !5, elements: !6, identifier: "_ZTS4Base")
  66. !5 = !DIFile(filename: "./a.hpp", directory: "/Users/mren/c_testing/type_unique_air/simple")
  67. !6 = !{!7}
  68. !7 = !DIDerivedType(tag: DW_TAG_member, name: "a", line: 2, size: 32, align: 32, file: !5, scope: !"_ZTS4Base", baseType: !8)
  69. !8 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
  70. !9 = !{!10}
  71. !10 = !DISubprogram(name: "f", linkageName: "_Z1fi", line: 3, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 3, file: !1, scope: !11, type: !12, function: void (i32)* @_Z1fi, variables: !2)
  72. !11 = !DIFile(filename: "foo.cpp", directory: "/Users/mren/c_testing/type_unique_air/simple")
  73. !12 = !DISubroutineType(types: !13)
  74. !13 = !{null, !8}
  75. !14 = !{i32 2, !"Dwarf Version", i32 2}
  76. !15 = !DILocalVariable(tag: DW_TAG_arg_variable, name: "a", line: 3, arg: 1, scope: !10, file: !11, type: !8)
  77. !16 = !DILocation(line: 3, scope: !10)
  78. !17 = !DILocalVariable(tag: DW_TAG_auto_variable, name: "t", line: 4, scope: !10, file: !11, type: !4)
  79. !18 = !DILocation(line: 4, scope: !10)
  80. !19 = !DILocation(line: 5, scope: !10)
  81. !20 = !{i32 1, !"Debug Info Version", i32 3}