1; REQUIRES: object-emission 2 3; RUN: llc < %s -o %t -filetype=obj -O0 -generate-type-units -mtriple=x86_64-unknown-linux-gnu 4; RUN: llvm-dwarfdump -v %t | FileCheck --check-prefix=CHECK --check-prefix=SINGLE %s 5; RUN: llvm-readobj -s -t %t | FileCheck --check-prefix=OBJ_SINGLE %s 6 7; RUN: llc < %s -split-dwarf-file=foo.dwo -o %t -filetype=obj -O0 -generate-type-units -mtriple=x86_64-unknown-linux-gnu 8; RUN: llvm-dwarfdump -v %t | FileCheck --check-prefix=CHECK --check-prefix=FISSION %s 9; RUN: llvm-readobj -s -t %t | FileCheck --check-prefix=OBJ_FISSION %s 10 11; Generated from bar.cpp: 12 13; #line 1 "bar.h" 14; struct bar {}; 15; #line 2 "bar.cpp" 16 17; struct bar b; 18 19; void foo(void) { 20; struct baz {}; 21; baz b; 22; } 23 24; namespace echidna { 25; namespace capybara { 26; namespace mongoose { 27; class fluffy { 28; int a; 29; int b; 30; }; 31 32; fluffy animal; 33; } 34; } 35; } 36 37; namespace { 38; struct walrus { 39; walrus() {} 40; }; 41; } 42 43; walrus w; 44 45; struct wombat { 46; struct { 47; int a; 48; int b; 49; } a_b; 50; }; 51 52; wombat wom; 53 54; SINGLE-LABEL: .debug_info contents: 55; FISSION-LABEL: .debug_info.dwo contents: 56; CHECK: Compile Unit: length = [[CU_SIZE:[0-9a-f]+]] 57 58; CHECK: [[BAR:^0x........]]: DW_TAG_structure_type 59; CHECK-NEXT: DW_AT_declaration 60; CHECK-NEXT: DW_AT_signature {{.*}} (0x1d02f3be30cc5688) 61; CHECK: [[FLUFFY:^0x........]]: DW_TAG_class_type 62; CHECK-NEXT: DW_AT_declaration 63; CHECK-NEXT: DW_AT_signature {{.*}} (0xb04af47397402e77) 64 65; Ensure the CU-local type 'walrus' is not placed in a type unit. 66; CHECK: [[WALRUS:^0x........]]: DW_TAG_structure_type 67; CHECK-NEXT: DW_AT_name{{.*}}"walrus" 68; CHECK-NEXT: DW_AT_byte_size 69; CHECK-NEXT: DW_AT_decl_file 70; CHECK-NEXT: DW_AT_decl_line 71 72; CHECK: [[WOMBAT:^0x........]]: DW_TAG_structure_type 73; CHECK-NEXT: DW_AT_declaration 74; CHECK-NEXT: DW_AT_signature {{.*}} (0xfd756cee88f8a118) 75 76; SINGLE-LABEL: .debug_types contents: 77; FISSION: .debug_types.dwo contents: 78 79; Check that we generate a hash for bar and the value. 80; CHECK-NOT: type_signature 81; CHECK-LABEL: type_signature = 0x1d02f3be30cc5688 82; CHECK: DW_TAG_structure_type 83; FISSION-NEXT: DW_AT_name {{.*}} ( indexed {{.*}} "bar" 84; SINGLE-NEXT: DW_AT_name {{.*}} "bar" 85 86; Check that we generate a hash for fluffy and the value. 87; CHECK-NOT: type_signature 88; CHECK-LABEL: type_signature = 0xb04af47397402e77 89; CHECK-NOT: DW_AT_GNU_odr_signature [DW_FORM_data8] (0x9a0124d5a0c21c52) 90; CHECK: DW_TAG_namespace 91; CHECK-NEXT: DW_AT_name{{.*}}"echidna" 92; CHECK: DW_TAG_namespace 93; CHECK-NEXT: DW_AT_name{{.*}}"capybara" 94; CHECK: DW_TAG_namespace 95; CHECK-NEXT: DW_AT_name{{.*}}"mongoose" 96; CHECK: DW_TAG_class_type 97; CHECK-NEXT: DW_AT_name{{.*}}"fluffy" 98 99; Check that we generate a hash for wombat and the value, but not for the 100; anonymous type contained within. 101; CHECK-NOT: type_signature 102; CHECK-LABEL: type_signature = 0xfd756cee88f8a118 103; CHECK-NOT: DW_AT_GNU_odr_signature [DW_FORM_data8] (0x685bcc220141e9d7) 104; CHECK: DW_TAG_structure_type 105; CHECK-NEXT: DW_AT_name{{.*}}"wombat" 106 107; CHECK-NOT: type_signature 108; CHECK-LABEL: type_signature = 0xe94f6d3843e62d6b 109; CHECK: DW_TAG_type_unit 110; CHECK: DW_AT_stmt_list [DW_FORM_sec_offset] (0x00000000) 111; CHECK-NOT: NULL 112; CHECK-NOT: DW_AT_GNU_odr_signature 113; CHECK: DW_TAG_structure_type 114; The signature for the outer 'wombat' type 115; CHECK: DW_AT_signature [DW_FORM_ref_sig8] (0xfd756cee88f8a118) 116; CHECK: DW_TAG_structure_type 117; CHECK-NOT: DW_AT_name 118; CHECK-NOT: DW_AT_GNU_odr_signature 119; CHECK: DW_TAG_member 120; CHECK-NEXT: DW_AT_name{{.*}}"a" 121 122; CHECK-LABEL: .debug_line contents: 123; CHECK: Line table prologue 124; CHECK-NOT: file_names[ 125; SINGLE: file_names[ 126; SINGLE-NEXT: name: "bar.h" 127; CHECK: file_names[ 128; CHECK-NEXT: name: "bar.cpp" 129; CHECK-NOT: file_names[ 130 131; FISSION: .debug_line.dwo contents: 132; CHECK-NOT: .debug_line.dwo contents: 133; FISSION: Line table prologue 134; FISSION: opcode_base: 1 135; FISSION-NOT: standard_opcode_lengths 136; FISSION-NOT: include_directories 137; FISSION-NOT: file_names[ 138; FISSION: file_names[ 139; FISSION-NEXT: name: "bar.h" 140; FISSION: file_names[ 141; FISSION-NEXT: name: "bar.cpp" 142; FISSION-NOT: file_names[ 143 144; CHECK-LABEL: .debug_str contents: 145 146; Use the unit size as a rough hash/identifier for the unit we're dealing with 147; it happens to be unambiguous at the moment, but it's hardly ideal. 148; CHECK-LABEL: .debug_pubtypes contents: 149; Don't emit pubtype entries for type DIEs in the compile unit that just indirect to a type unit. 150; CHECK-NEXT: unit_size = [[CU_SIZE]] 151; CHECK-NEXT: Offset Name 152; CHECK-DAG: [[BAR]] "bar" 153; CHECK-DAG: [[WALRUS]] "(anonymous namespace)::walrus" 154; CHECK-DAG: [[WOMBAT]] "wombat" 155; CHECK-DAG: [[FLUFFY]] "echidna::capybara::mongoose::fluffy" 156 157; Make sure debug_types are in comdat groups. This could be more rigid to check 158; that they're the right comdat groups (each type in a separate comdat group, 159; etc) 160; OBJ_SINGLE: Name: .debug_types ( 161; OBJ_SINGLE-NOT: } 162; OBJ_SINGLE: SHF_GROUP 163 164; Fission type units don't go in comdat groups, since their linker is debug 165; aware it's handled using the debug info semantics rather than raw ELF object 166; semantics. 167; OBJ_FISSION: Name: .debug_types.dwo ( 168; OBJ_FISSION-NOT: SHF_GROUP 169; OBJ_FISSION: } 170 171source_filename = "test/DebugInfo/X86/generate-odr-hash.ll" 172 173%struct.bar = type { i8 } 174%"class.echidna::capybara::mongoose::fluffy" = type { i32, i32 } 175%"struct.<anonymous namespace>::walrus" = type { i8 } 176%struct.wombat = type { %struct.anon } 177%struct.anon = type { i32, i32 } 178%struct.baz = type { i8 } 179 180@b = global %struct.bar zeroinitializer, align 1, !dbg !0 181@_ZN7echidna8capybara8mongoose6animalE = global %"class.echidna::capybara::mongoose::fluffy" zeroinitializer, align 4, !dbg !6 182@w = internal global %"struct.<anonymous namespace>::walrus" zeroinitializer, align 1, !dbg !16 183@wom = global %struct.wombat zeroinitializer, align 4, !dbg !25 184@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_a }] 185 186; Function Attrs: nounwind uwtable 187define void @_Z3foov() #0 !dbg !40 { 188entry: 189 %b = alloca %struct.baz, align 1 190 call void @llvm.dbg.declare(metadata %struct.baz* %b, metadata !43, metadata !45), !dbg !46 191 ret void, !dbg !47 192} 193 194; Function Attrs: nounwind readnone 195declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 196 197define internal void @__cxx_global_var_init() section ".text.startup" !dbg !48 { 198entry: 199 call void @_ZN12_GLOBAL__N_16walrusC2Ev(%"struct.<anonymous namespace>::walrus"* @w), !dbg !49 200 ret void, !dbg !49 201} 202 203; Function Attrs: nounwind uwtable 204define internal void @_ZN12_GLOBAL__N_16walrusC2Ev(%"struct.<anonymous namespace>::walrus"* %this) unnamed_addr #0 align 2 !dbg !50 { 205entry: 206 %this.addr = alloca %"struct.<anonymous namespace>::walrus"*, align 8 207 store %"struct.<anonymous namespace>::walrus"* %this, %"struct.<anonymous namespace>::walrus"** %this.addr, align 8 208 call void @llvm.dbg.declare(metadata %"struct.<anonymous namespace>::walrus"** %this.addr, metadata !51, metadata !45), !dbg !53 209 %this1 = load %"struct.<anonymous namespace>::walrus"*, %"struct.<anonymous namespace>::walrus"** %this.addr 210 ret void, !dbg !54 211} 212 213define internal void @_GLOBAL__I_a() section ".text.startup" !dbg !55 { 214entry: 215 call void @__cxx_global_var_init(), !dbg !57 216 ret void, !dbg !57 217} 218 219attributes #0 = { nounwind 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" } 220attributes #1 = { nounwind readnone } 221 222!llvm.dbg.cu = !{!34} 223!llvm.module.flags = !{!37, !38} 224!llvm.ident = !{!39} 225 226!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) 227!1 = !DIGlobalVariable(name: "b", scope: null, file: !2, line: 3, type: !3, isLocal: false, isDefinition: true) 228!2 = !DIFile(filename: "bar.cpp", directory: "/tmp/dbginfo") 229!3 = !DICompositeType(tag: DW_TAG_structure_type, name: "bar", file: !4, line: 1, size: 8, align: 8, elements: !5, identifier: "_ZTS3bar") 230!4 = !DIFile(filename: "bar.h", directory: "/tmp/dbginfo") 231!5 = !{} 232!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression()) 233!7 = !DIGlobalVariable(name: "animal", linkageName: "_ZN7echidna8capybara8mongoose6animalE", scope: !8, file: !2, line: 18, type: !11, isLocal: false, isDefinition: true) 234!8 = !DINamespace(name: "mongoose", scope: !9) 235!9 = !DINamespace(name: "capybara", scope: !10) 236!10 = !DINamespace(name: "echidna", scope: null) 237!11 = !DICompositeType(tag: DW_TAG_class_type, name: "fluffy", scope: !8, file: !2, line: 13, size: 64, align: 32, elements: !12, identifier: "_ZTSN7echidna8capybara8mongoose6fluffyE") 238!12 = !{!13, !15} 239!13 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !11, file: !2, line: 14, baseType: !14, size: 32, align: 32, flags: DIFlagPrivate) 240!14 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 241!15 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !11, file: !2, line: 15, baseType: !14, size: 32, align: 32, offset: 32, flags: DIFlagPrivate) 242!16 = !DIGlobalVariableExpression(var: !17, expr: !DIExpression()) 243!17 = !DIGlobalVariable(name: "w", scope: null, file: !2, line: 29, type: !18, isLocal: true, isDefinition: true) 244!18 = !DICompositeType(tag: DW_TAG_structure_type, name: "walrus", scope: !19, file: !2, line: 24, size: 8, align: 8, elements: !20) 245!19 = !DINamespace(scope: null) 246!20 = !{!21} 247!21 = !DISubprogram(name: "walrus", scope: !18, file: !2, line: 25, type: !22, isLocal: false, isDefinition: false, scopeLine: 25, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false) 248!22 = !DISubroutineType(types: !23) 249!23 = !{null, !24} 250!24 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !18, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer) 251!25 = !DIGlobalVariableExpression(var: !26, expr: !DIExpression()) 252!26 = !DIGlobalVariable(name: "wom", scope: null, file: !2, line: 38, type: !27, isLocal: false, isDefinition: true) 253!27 = !DICompositeType(tag: DW_TAG_structure_type, name: "wombat", file: !2, line: 31, size: 64, align: 32, elements: !28, identifier: "_ZTS6wombat") 254!28 = !{!29} 255!29 = !DIDerivedType(tag: DW_TAG_member, name: "a_b", scope: !27, file: !2, line: 35, baseType: !30, size: 64, align: 32) 256!30 = !DICompositeType(tag: DW_TAG_structure_type, scope: !27, file: !2, line: 32, size: 64, align: 32, elements: !31, identifier: "_ZTSN6wombatUt_E") 257!31 = !{!32, !33} 258!32 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !30, file: !2, line: 33, baseType: !14, size: 32, align: 32) 259!33 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !30, file: !2, line: 34, baseType: !14, size: 32, align: 32, offset: 32) 260!34 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !2, producer: "clang version 3.5 ", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "bar.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !35, globals: !36, imports: !5) 261!35 = !{!3, !11, !27, !30} 262!36 = !{!0, !6, !16, !25} 263!37 = !{i32 2, !"Dwarf Version", i32 4} 264!38 = !{i32 1, !"Debug Info Version", i32 3} 265!39 = !{!"clang version 3.5 "} 266!40 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !2, file: !2, line: 5, type: !41, isLocal: false, isDefinition: true, scopeLine: 5, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !34, retainedNodes: !5) 267!41 = !DISubroutineType(types: !42) 268!42 = !{null} 269!43 = !DILocalVariable(name: "b", scope: !40, file: !2, line: 7, type: !44) 270!44 = !DICompositeType(tag: DW_TAG_structure_type, name: "baz", scope: !40, file: !2, line: 6, size: 8, align: 8, elements: !5) 271!45 = !DIExpression() 272!46 = !DILocation(line: 7, scope: !40) 273!47 = !DILocation(line: 8, scope: !40) 274!48 = distinct !DISubprogram(name: "__cxx_global_var_init", scope: !2, file: !2, line: 29, type: !41, isLocal: true, isDefinition: true, scopeLine: 29, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !34, retainedNodes: !5) 275!49 = !DILocation(line: 29, scope: !48) 276!50 = distinct !DISubprogram(name: "walrus", linkageName: "_ZN12_GLOBAL__N_16walrusC2Ev", scope: !18, file: !2, line: 25, type: !22, isLocal: true, isDefinition: true, scopeLine: 25, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !34, declaration: !21, retainedNodes: !5) 277!51 = !DILocalVariable(name: "this", arg: 1, scope: !50, type: !52, flags: DIFlagArtificial | DIFlagObjectPointer) 278!52 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !18, size: 64, align: 64) 279!53 = !DILocation(line: 0, scope: !50) 280!54 = !DILocation(line: 25, scope: !50) 281!55 = distinct !DISubprogram(linkageName: "_GLOBAL__I_a", scope: !2, file: !2, line: 25, type: !56, isLocal: true, isDefinition: true, scopeLine: 25, virtualIndex: 6, flags: DIFlagArtificial, isOptimized: false, unit: !34, retainedNodes: !5) 282!56 = !DISubroutineType(types: !5) 283!57 = !DILocation(line: 25, scope: !55) 284 285