tu-composite.ll 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. ; REQUIRES: object-emission
  2. ; RUN: %llc_dwarf -filetype=obj -O0 < %s > %t
  3. ; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck %s
  4. ; CHECK: [[TYPE:.*]]: DW_TAG_structure_type
  5. ; Make sure we correctly handle containing type of a struct being a type identifier.
  6. ; CHECK-NEXT: DW_AT_containing_type [DW_FORM_ref4] (cu + {{.*}} => {[[TYPE]]})
  7. ; CHECK-NEXT: DW_AT_name [DW_FORM_strp] {{.*}}= "C")
  8. ; Make sure we correctly handle context of a subprogram being a type identifier.
  9. ; CHECK: [[SP:.*]]: DW_TAG_subprogram
  10. ; CHECK: DW_AT_name [DW_FORM_strp] {{.*}}= "foo")
  11. ; Make sure we correctly handle containing type of a subprogram being a type identifier.
  12. ; CHECK: DW_AT_containing_type [DW_FORM_ref4] (cu + {{.*}} => {[[TYPE]]})
  13. ; CHECK: DW_TAG_formal_parameter
  14. ; CHECK: NULL
  15. ; CHECK: NULL
  16. ; CHECK: [[TYPE2:.*]]: DW_TAG_structure_type
  17. ; CHECK: DW_AT_name [DW_FORM_strp] {{.*}}= "bar")
  18. ; CHECK: DW_TAG_structure_type
  19. ; CHECK: DW_AT_name [DW_FORM_strp] {{.*}}= "D")
  20. ; CHECK: DW_TAG_member
  21. ; CHECK: DW_AT_name [DW_FORM_strp] {{.*}}= "a")
  22. ; Make sure we correctly handle context of a struct being a type identifier.
  23. ; CHECK: DW_TAG_structure_type
  24. ; CHECK-NEXT: DW_AT_name [DW_FORM_strp] {{.*}}= "Nested")
  25. ; CHECK: DW_TAG_structure_type
  26. ; CHECK-NEXT: DW_AT_name [DW_FORM_strp] {{.*}}= "Nested2")
  27. ; CHECK-NEXT: DW_AT_declaration [DW_FORM_flag] (0x01)
  28. ; CHECK: DW_TAG_structure_type
  29. ; CHECK-NEXT: DW_AT_name [DW_FORM_strp] {{.*}}= "virt<bar>")
  30. ; Make sure we correctly handle type of a template_type being a type identifier.
  31. ; CHECK: DW_TAG_template_type_parameter
  32. ; CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (cu + {{.*}} => {[[TYPE2]]}
  33. ; CHECK-NEXT: DW_AT_name [DW_FORM_strp] {{.*}}= "T")
  34. ; Make sure we correctly handle derived-from of a typedef being a type identifier.
  35. ; CHECK: DW_TAG_typedef
  36. ; CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (cu + {{.*}} => {[[TYPE2]]}
  37. ; CHECK: DW_AT_name [DW_FORM_strp] {{.*}}= "baz2")
  38. ; Make sure we correctly handle derived-from of a pointer type being a type identifier.
  39. ; CHECK: DW_TAG_pointer_type
  40. ; CHECK: DW_AT_type [DW_FORM_ref4] (cu + {{.*}} => {[[TYPE]]}
  41. ; CHECK: DW_TAG_typedef
  42. ; CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (cu + {{.*}} => {[[TYPE2]]}
  43. ; CHECK: DW_AT_name [DW_FORM_strp] {{.*}}= "baz")
  44. ; Make sure we correctly handle derived-from of an array type being a type identifier.
  45. ; CHECK: DW_TAG_array_type
  46. ; CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (cu + {{.*}} => {[[TYPE2]]}
  47. ; IR generated from clang -g with the following source:
  48. ; struct C {
  49. ; virtual void foo();
  50. ; };
  51. ; void C::foo() {
  52. ; }
  53. ;
  54. ; struct bar { };
  55. ; typedef bar baz;
  56. ; struct D {
  57. ; typedef bar baz2;
  58. ; static int a;
  59. ; struct Nested { };
  60. ; struct Nested2 { };
  61. ; template <typename T>
  62. ; struct virt {
  63. ; T* values;
  64. ; };
  65. ; };
  66. ; void test() {
  67. ; baz B;
  68. ; bar A[3];
  69. ; D::baz2 B2;
  70. ; D::Nested e;
  71. ; D::Nested2 *p;
  72. ; D::virt<bar> t;
  73. ; }
  74. %struct.C = type { i32 (...)** }
  75. %struct.bar = type { i8 }
  76. %"struct.D::Nested" = type { i8 }
  77. %"struct.D::Nested2" = type { i8 }
  78. %"struct.D::virt" = type { %struct.bar* }
  79. @_ZTV1C = unnamed_addr constant [3 x i8*] [i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI1C to i8*), i8* bitcast (void (%struct.C*)* @_ZN1C3fooEv to i8*)]
  80. @_ZTVN10__cxxabiv117__class_type_infoE = external global i8*
  81. @_ZTS1C = constant [3 x i8] c"1C\00"
  82. @_ZTI1C = unnamed_addr constant { i8*, i8* } { i8* bitcast (i8** getelementptr inbounds (i8*, i8** @_ZTVN10__cxxabiv117__class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @_ZTS1C, i32 0, i32 0) }
  83. ; Function Attrs: nounwind ssp uwtable
  84. define void @_ZN1C3fooEv(%struct.C* %this) unnamed_addr #0 align 2 !dbg !31 {
  85. entry:
  86. %this.addr = alloca %struct.C*, align 8
  87. store %struct.C* %this, %struct.C** %this.addr, align 8
  88. call void @llvm.dbg.declare(metadata %struct.C** %this.addr, metadata !36, metadata !DIExpression()), !dbg !38
  89. %this1 = load %struct.C*, %struct.C** %this.addr
  90. ret void, !dbg !39
  91. }
  92. ; Function Attrs: nounwind readnone
  93. declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
  94. ; Function Attrs: nounwind ssp uwtable
  95. define void @_Z4testv() #0 !dbg !32 {
  96. entry:
  97. %B = alloca %struct.bar, align 1
  98. %A = alloca [3 x %struct.bar], align 1
  99. %B2 = alloca %struct.bar, align 1
  100. %e = alloca %"struct.D::Nested", align 1
  101. %p = alloca %"struct.D::Nested2"*, align 8
  102. %t = alloca %"struct.D::virt", align 8
  103. call void @llvm.dbg.declare(metadata %struct.bar* %B, metadata !40, metadata !DIExpression()), !dbg !42
  104. call void @llvm.dbg.declare(metadata [3 x %struct.bar]* %A, metadata !43, metadata !DIExpression()), !dbg !47
  105. call void @llvm.dbg.declare(metadata %struct.bar* %B2, metadata !48, metadata !DIExpression()), !dbg !50
  106. call void @llvm.dbg.declare(metadata %"struct.D::Nested"* %e, metadata !51, metadata !DIExpression()), !dbg !52
  107. call void @llvm.dbg.declare(metadata %"struct.D::Nested2"** %p, metadata !53, metadata !DIExpression()), !dbg !55
  108. call void @llvm.dbg.declare(metadata %"struct.D::virt"* %t, metadata !56, metadata !DIExpression()), !dbg !57
  109. ret void, !dbg !58
  110. }
  111. 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" }
  112. attributes #1 = { nounwind readnone }
  113. !llvm.dbg.cu = !{!0}
  114. !llvm.module.flags = !{!35, !59}
  115. !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.4", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !3, globals: !2, imports: !2)
  116. !1 = !DIFile(filename: "tmp.cpp", directory: ".")
  117. !2 = !{}
  118. !3 = !{!4, !18, !19, !22, !23, !24}
  119. !4 = !DICompositeType(tag: DW_TAG_structure_type, name: "C", line: 1, file: !1, elements: !5, vtableHolder: !4, identifier: "_ZTS1C")
  120. !5 = !{!6, !13}
  121. !6 = !DIDerivedType(tag: DW_TAG_member, name: "_vptr$C", flags: DIFlagArtificial, file: !1, scope: !7, baseType: !8)
  122. !7 = !DIFile(filename: "tmp.cpp", directory: ".")
  123. !8 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, baseType: !9)
  124. !9 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "__vtbl_ptr_type", size: 64, baseType: !10)
  125. !10 = !DISubroutineType(types: !11)
  126. !11 = !{!12}
  127. !12 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
  128. !13 = !DISubprogram(name: "foo", linkageName: "_ZN1C3fooEv", line: 2, isLocal: false, isDefinition: false, virtuality: DW_VIRTUALITY_virtual, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 2, file: !1, scope: !4, type: !14, containingType: !4)
  129. !14 = !DISubroutineType(types: !15)
  130. !15 = !{null, !16}
  131. !16 = !DIDerivedType(tag: DW_TAG_pointer_type, flags: DIFlagArtificial | DIFlagObjectPointer, baseType: !4)
  132. !18 = !DICompositeType(tag: DW_TAG_structure_type, name: "bar", line: 7, size: 8, align: 8, file: !1, elements: !2, identifier: "_ZTS3bar")
  133. !19 = !DICompositeType(tag: DW_TAG_structure_type, name: "D", line: 9, size: 8, align: 8, file: !1, elements: !20, identifier: "_ZTS1D")
  134. !20 = !{!21}
  135. !21 = !DIDerivedType(tag: DW_TAG_member, name: "a", line: 11, flags: DIFlagStaticMember, file: !1, scope: !19, baseType: !12)
  136. !22 = !DICompositeType(tag: DW_TAG_structure_type, name: "Nested", line: 12, size: 8, align: 8, file: !1, scope: !19, elements: !2, identifier: "_ZTSN1D6NestedE")
  137. !23 = !DICompositeType(tag: DW_TAG_structure_type, name: "Nested2", line: 13, flags: DIFlagFwdDecl, file: !1, scope: !19, identifier: "_ZTSN1D7Nested2E")
  138. !24 = !DICompositeType(tag: DW_TAG_structure_type, name: "virt<bar>", line: 15, file: !1, scope: !19, elements: !25, templateParams: !28, identifier: "_ZTSN1D4virtI3barEE")
  139. !25 = !{!26}
  140. !26 = !DIDerivedType(tag: DW_TAG_member, name: "values", line: 16, size: 64, align: 64, file: !1, scope: !24, baseType: !27)
  141. !27 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !18)
  142. !28 = !{!29}
  143. !29 = !DITemplateTypeParameter(name: "T", type: !18)
  144. !31 = distinct !DISubprogram(name: "foo", linkageName: "_ZN1C3fooEv", line: 4, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 4, file: !1, scope: null, type: !14, declaration: !13, retainedNodes: !2)
  145. !32 = distinct !DISubprogram(name: "test", linkageName: "_Z4testv", line: 20, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 20, file: !1, scope: !7, type: !33, retainedNodes: !2)
  146. !33 = !DISubroutineType(types: !34)
  147. !34 = !{null}
  148. !35 = !{i32 2, !"Dwarf Version", i32 2}
  149. !36 = !DILocalVariable(name: "this", arg: 1, flags: DIFlagArtificial | DIFlagObjectPointer, scope: !31, type: !37)
  150. !37 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !4)
  151. !38 = !DILocation(line: 0, scope: !31)
  152. !39 = !DILocation(line: 5, scope: !31)
  153. !40 = !DILocalVariable(name: "B", line: 21, scope: !32, file: !7, type: !41)
  154. !41 = !DIDerivedType(tag: DW_TAG_typedef, name: "baz", line: 8, file: !1, baseType: !18)
  155. !42 = !DILocation(line: 21, scope: !32)
  156. !43 = !DILocalVariable(name: "A", line: 22, scope: !32, file: !7, type: !44)
  157. !44 = !DICompositeType(tag: DW_TAG_array_type, size: 24, align: 8, baseType: !18, elements: !45)
  158. !45 = !{!46}
  159. !46 = !DISubrange(count: 3)
  160. !47 = !DILocation(line: 22, scope: !32)
  161. !48 = !DILocalVariable(name: "B2", line: 23, scope: !32, file: !7, type: !49)
  162. !49 = !DIDerivedType(tag: DW_TAG_typedef, name: "baz2", line: 10, file: !1, scope: !19, baseType: !18)
  163. !50 = !DILocation(line: 23, scope: !32)
  164. !51 = !DILocalVariable(name: "e", line: 24, scope: !32, file: !7, type: !22)
  165. !52 = !DILocation(line: 24, scope: !32)
  166. !53 = !DILocalVariable(name: "p", line: 25, scope: !32, file: !7, type: !54)
  167. !54 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !23)
  168. !55 = !DILocation(line: 25, scope: !32)
  169. !56 = !DILocalVariable(name: "t", line: 26, scope: !32, file: !7, type: !24)
  170. !57 = !DILocation(line: 26, scope: !32)
  171. !58 = !DILocation(line: 27, scope: !32)
  172. !59 = !{i32 1, !"Debug Info Version", i32 3}