158 lines · plain
1; RUN: llc -mtriple=x86_64-unknown-linux-gnu -filetype=obj < %s | llvm-dwarfdump -v - | \2; RUN: FileCheck --check-prefix=DEFAULT --check-prefix=BOTH %s3; RUN: llc -mtriple=x86_64-unknown-linux-gnu -filetype=obj -generate-type-units < %s | \4; RUN: llvm-dwarfdump -v - | FileCheck --check-prefix=TYPEUNITS --check-prefix=BOTH %s5;6; Check that we generate the DWARF v5 string offsets section correctly when we7; have multiple compile and type units. All units share one contribution to8; the string offsets section.9;10; Constructed from the following sources with11; clang -gdwarf-5 -emit-llvm -S a.cpp12; clang -gdwarf-5 -emit-llvm -S b.cpp13; clang -gdwarf-5 -emit-llvm -S c.cpp14; llvm-link a.ll b.ll c.ll -o test.bc15; llvm-dis test.bc -o test.ll16;17; a.cpp:18; enum E1 {a, b, c};19; E1 glob1;20;21; b.cpp:22; enum E2 {d, e, f};23; E2 glob2;24;25; c.cpp:26; enum E3 {g, h, i};27; E3 glob3;28;29; Check that all 3 compile units have the correct DW_AT_str_offsets_base attributes30; with the correct offsets. Check that strings referenced by compile units 2 and 331; are displayed correctly.32;33; BOTH: .debug_info contents:34;35; Verify that all 3 type units have the proper DW_AT_str_offsets_base attribute.36; TYPEUNITS-NOT: contents:37; TYPEUNITS: DW_TAG_type_unit38; TYPEUNITS-NOT: {{DW_TAG|NULL}}39; TYPEUNITS: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x[[CU1_STROFF:[0-9a-f]+]])40; TYPEUNITS-NOT: NULL41; TYPEUNITS: DW_TAG_enumerator42; TYPEUNITS-NOT: NULL43; TYPEUNITS: DW_TAG_enumerator44; TYPEUNITS-NOT: {{DW_TAG|NULL}}45; TYPEUNITS: DW_AT_name [DW_FORM_strx1] (indexed (00000005) string = "b")46; TYPEUNITS-NOT: contents:47; TYPEUNITS: DW_TAG_type_unit48; TYPEUNITS-NOT: {{DW_TAG|NULL}}49; TYPEUNITS: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x[[CU1_STROFF]])50; TYPEUNITS-NOT: NULL51; TYPEUNITS: DW_TAG_enumeration_type52; TYPEUNITS: DW_AT_name [DW_FORM_strx1] (indexed (0000000d) string = "E2")53; TYPEUNITS-NOT: contents:54; TYPEUNITS: DW_TAG_type_unit55; TYPEUNITS-NOT: {{DW_TAG|NULL}}56; TYPEUNITS: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x[[CU1_STROFF]])57; TYPEUNITS-NOT: NULL58; TYPEUNITS: DW_TAG_enumeration_type59; TYPEUNITS: DW_AT_name [DW_FORM_strx1] (indexed (00000013) string = "E3")60 61; CU 162; BOTH-NOT: .contents:63; BOTH: DW_TAG_compile_unit64; BOTH-NOT: {{DW_TAG|NULL}}65; DEFAULT: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x[[CU1_STROFF:[0-9a-f]+]])66; TYPEUNITS: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x[[CU1_STROFF]])67;68; CU 269; BOTH-NOT: contents:70; BOTH: DW_TAG_compile_unit71; BOTH-NOT: {{DW_TAG|NULL}}72; BOTH: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x[[CU1_STROFF]])73; BOTH-NOT: NULL74; BOTH: DW_TAG_variable75; BOTH-NOT: {{DW_TAG|NULL}}76; BOTH: DW_AT_name [DW_FORM_strx1] (indexed (00000009) string = "glob2")77;78; CU 379; BOTH-NOT: contents:80; BOTH: DW_TAG_compile_unit81; BOTH-NOT: {{DW_TAG|NULL}}82; BOTH: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x[[CU1_STROFF]])83; BOTH-NOT: NULL84; BOTH: DW_TAG_variable85; BOTH-NOT: {{DW_TAG|NULL}}86; BOTH: DW_AT_name [DW_FORM_strx1] (indexed (0000000f) string = "glob3")87;88; Extract the offset of a string to verify that it is referenced in the string89; offsets section.90; BOTH: .debug_str contents:91; BOTH-NOT: contents:92; BOTH: 0x[[GLOB2OFF:[0-9a-f]+]]: "glob2"93;94; Check the .debug_str_offsets section header and make sure the referenced string95; has the correct offset.96; BOTH: .debug_str_offsets contents:97; BOTH-NEXT: 0x00000000: Contribution size = 84, Format = DWARF32, Version = 598; BOTH-NEXT: 0x[[CU1_STROFF]]:99; BOTH-NEXT: {{.*:}}100; BOTH-NEXT: {{.*:}}101; BOTH-NEXT: {{.*:}}102; BOTH-NEXT: {{.*:}}103; BOTH-NEXT: {{.*:}}104; BOTH-NEXT: {{.*:}}105; BOTH-NEXT: {{.*:}}106; BOTH-NEXT: {{.*:}}107; The string with index 9 should be "glob2"108; BOTH-NEXT: {{.*:}} [[GLOB2OFF]]109;110; ModuleID = 'test.bc'111source_filename = "llvm-link"112 113@glob1 = global i32 0, align 4, !dbg !0114@glob2 = global i32 0, align 4, !dbg !11115@glob3 = global i32 0, align 4, !dbg !22116 117!llvm.dbg.cu = !{!2, !13, !24}118!llvm.ident = !{!33, !33, !33}119!llvm.module.flags = !{!34, !35, !36}120 121!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())122!1 = distinct !DIGlobalVariable(name: "glob1", scope: !2, file: !3, line: 2, type: !5, isLocal: false, isDefinition: true)123!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 7.0.0 (trunk 322415)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !10)124!3 = !DIFile(filename: "a1.cpp", directory: "/home/test", checksumkind: CSK_MD5, checksum: "2ca3eeed18355d6ebbae671eafda5aae")125!4 = !{!5}126!5 = distinct !DICompositeType(tag: DW_TAG_enumeration_type, name: "E1", file: !3, line: 1, size: 32, elements: !6, identifier: "_ZTS2E1")127!6 = !{!7, !8, !9}128!7 = !DIEnumerator(name: "a", value: 0)129!8 = !DIEnumerator(name: "b", value: 1)130!9 = !DIEnumerator(name: "c", value: 2)131!10 = !{!0}132!11 = !DIGlobalVariableExpression(var: !12, expr: !DIExpression())133!12 = distinct !DIGlobalVariable(name: "glob2", scope: !13, file: !14, line: 2, type: !16, isLocal: false, isDefinition: true)134!13 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !14, producer: "clang version 7.0.0 (trunk 322415)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !15, globals: !21)135!14 = !DIFile(filename: "b.cpp", directory: "/home/test", checksumkind: CSK_MD5, checksum: "0e254f89617ecb6c4e5473546a99435c")136!15 = !{!16}137!16 = distinct !DICompositeType(tag: DW_TAG_enumeration_type, name: "E2", file: !14, line: 1, size: 32, elements: !17, identifier: "_ZTS2E2")138!17 = !{!18, !19, !20}139!18 = !DIEnumerator(name: "d", value: 0)140!19 = !DIEnumerator(name: "e", value: 1)141!20 = !DIEnumerator(name: "f", value: 2)142!21 = !{!11}143!22 = !DIGlobalVariableExpression(var: !23, expr: !DIExpression())144!23 = distinct !DIGlobalVariable(name: "glob3", scope: !24, file: !25, line: 2, type: !27, isLocal: false, isDefinition: true)145!24 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !25, producer: "clang version 7.0.0 (trunk 322415)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !26, globals: !32)146!25 = !DIFile(filename: "c.cpp", directory: "/home/test", checksumkind: CSK_MD5, checksum: "7835aaaa683fa09d295adef0e934d392")147!26 = !{!27}148!27 = distinct !DICompositeType(tag: DW_TAG_enumeration_type, name: "E3", file: !25, line: 1, size: 32, elements: !28, identifier: "_ZTS2E3")149!28 = !{!29, !30, !31}150!29 = !DIEnumerator(name: "g", value: 0)151!30 = !DIEnumerator(name: "h", value: 1)152!31 = !DIEnumerator(name: "i", value: 2)153!32 = !{!22}154!33 = !{!"clang version 7.0.0 (trunk 322415)"}155!34 = !{i32 2, !"Dwarf Version", i32 5}156!35 = !{i32 2, !"Debug Info Version", i32 3}157!36 = !{i32 1, !"wchar_size", i32 4}158