152dd7616SWolfgang Pieb; RUN: llc -mtriple=x86_64-unknown-linux-gnu -filetype=obj < %s | llvm-dwarfdump -v - | \ 29f23426cSWolfgang Pieb; RUN: FileCheck --check-prefix=DEFAULT --check-prefix=BOTH %s 352dd7616SWolfgang Pieb; RUN: llc -mtriple=x86_64-unknown-linux-gnu -filetype=obj -generate-type-units < %s | \ 49f23426cSWolfgang Pieb; RUN: llvm-dwarfdump -v - | FileCheck --check-prefix=TYPEUNITS --check-prefix=BOTH %s 59f23426cSWolfgang Pieb; 69f23426cSWolfgang Pieb; Check that we generate the DWARF v5 string offsets section correctly when we 79f23426cSWolfgang Pieb; have multiple compile and type units. All units share one contribution to 89f23426cSWolfgang Pieb; the string offsets section. 99f23426cSWolfgang Pieb; 109f23426cSWolfgang Pieb; Constructed from the following sources with 119f23426cSWolfgang Pieb; clang -gdwarf-5 -emit-llvm -S a.cpp 129f23426cSWolfgang Pieb; clang -gdwarf-5 -emit-llvm -S b.cpp 139f23426cSWolfgang Pieb; clang -gdwarf-5 -emit-llvm -S c.cpp 149f23426cSWolfgang Pieb; llvm-link a.ll b.ll c.ll -o test.bc 159f23426cSWolfgang Pieb; llvm-dis test.bc -o test.ll 169f23426cSWolfgang Pieb; 179f23426cSWolfgang Pieb; a.cpp: 189f23426cSWolfgang Pieb; enum E1 {a, b, c}; 199f23426cSWolfgang Pieb; E1 glob1; 209f23426cSWolfgang Pieb; 219f23426cSWolfgang Pieb; b.cpp: 229f23426cSWolfgang Pieb; enum E2 {d, e, f}; 239f23426cSWolfgang Pieb; E2 glob2; 249f23426cSWolfgang Pieb; 259f23426cSWolfgang Pieb; c.cpp: 269f23426cSWolfgang Pieb; enum E3 {g, h, i}; 279f23426cSWolfgang Pieb; E3 glob3; 289f23426cSWolfgang Pieb; 299f23426cSWolfgang Pieb; Check that all 3 compile units have the correct DW_AT_str_offsets_base attributes 309f23426cSWolfgang Pieb; with the correct offsets. Check that strings referenced by compile units 2 and 3 319f23426cSWolfgang Pieb; are displayed correctly. 329f23426cSWolfgang Pieb; 339f23426cSWolfgang Pieb; BOTH: .debug_info contents: 349f23426cSWolfgang Pieb; 359f23426cSWolfgang Pieb; Verify that all 3 type units have the proper DW_AT_str_offsets_base attribute. 369f23426cSWolfgang Pieb; TYPEUNITS-NOT: contents: 379f23426cSWolfgang Pieb; TYPEUNITS: DW_TAG_type_unit 389f23426cSWolfgang Pieb; TYPEUNITS-NOT: {{DW_TAG|NULL}} 39*ddbde9a4SPaul Robinson; TYPEUNITS: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x[[CU1_STROFF:[0-9a-f]+]]) 409f23426cSWolfgang Pieb; TYPEUNITS-NOT: NULL 419f23426cSWolfgang Pieb; TYPEUNITS: DW_TAG_enumerator 429f23426cSWolfgang Pieb; TYPEUNITS-NOT: NULL 439f23426cSWolfgang Pieb; TYPEUNITS: DW_TAG_enumerator 449f23426cSWolfgang Pieb; TYPEUNITS-NOT: {{DW_TAG|NULL}} 459f23426cSWolfgang Pieb; TYPEUNITS: DW_AT_name [DW_FORM_strx1] (indexed (00000005) string = "b") 469f23426cSWolfgang Pieb; TYPEUNITS-NOT: contents: 479f23426cSWolfgang Pieb; TYPEUNITS: DW_TAG_type_unit 489f23426cSWolfgang Pieb; TYPEUNITS-NOT: {{DW_TAG|NULL}} 499f23426cSWolfgang Pieb; TYPEUNITS: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x[[CU1_STROFF]]) 509f23426cSWolfgang Pieb; TYPEUNITS-NOT: NULL 519f23426cSWolfgang Pieb; TYPEUNITS: DW_TAG_enumeration_type 529f23426cSWolfgang Pieb; TYPEUNITS: DW_AT_name [DW_FORM_strx1] (indexed (0000000d) string = "E2") 539f23426cSWolfgang Pieb; TYPEUNITS-NOT: contents: 549f23426cSWolfgang Pieb; TYPEUNITS: DW_TAG_type_unit 559f23426cSWolfgang Pieb; TYPEUNITS-NOT: {{DW_TAG|NULL}} 569f23426cSWolfgang Pieb; TYPEUNITS: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x[[CU1_STROFF]]) 579f23426cSWolfgang Pieb; TYPEUNITS-NOT: NULL 589f23426cSWolfgang Pieb; TYPEUNITS: DW_TAG_enumeration_type 599f23426cSWolfgang Pieb; TYPEUNITS: DW_AT_name [DW_FORM_strx1] (indexed (00000013) string = "E3") 60*ddbde9a4SPaul Robinson 61*ddbde9a4SPaul Robinson; CU 1 62*ddbde9a4SPaul Robinson; BOTH-NOT: .contents: 63*ddbde9a4SPaul Robinson; BOTH: DW_TAG_compile_unit 64*ddbde9a4SPaul Robinson; BOTH-NOT: {{DW_TAG|NULL}} 65*ddbde9a4SPaul Robinson; DEFAULT: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x[[CU1_STROFF:[0-9a-f]+]]) 66*ddbde9a4SPaul Robinson; TYPEUNITS: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x[[CU1_STROFF]]) 67*ddbde9a4SPaul Robinson; 68*ddbde9a4SPaul Robinson; CU 2 69*ddbde9a4SPaul Robinson; BOTH-NOT: contents: 70*ddbde9a4SPaul Robinson; BOTH: DW_TAG_compile_unit 71*ddbde9a4SPaul Robinson; BOTH-NOT: {{DW_TAG|NULL}} 72*ddbde9a4SPaul Robinson; BOTH: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x[[CU1_STROFF]]) 73*ddbde9a4SPaul Robinson; BOTH-NOT: NULL 74*ddbde9a4SPaul Robinson; BOTH: DW_TAG_variable 75*ddbde9a4SPaul Robinson; BOTH-NOT: {{DW_TAG|NULL}} 76*ddbde9a4SPaul Robinson; BOTH: DW_AT_name [DW_FORM_strx1] (indexed (00000009) string = "glob2") 77*ddbde9a4SPaul Robinson; 78*ddbde9a4SPaul Robinson; CU 3 79*ddbde9a4SPaul Robinson; BOTH-NOT: contents: 80*ddbde9a4SPaul Robinson; BOTH: DW_TAG_compile_unit 81*ddbde9a4SPaul Robinson; BOTH-NOT: {{DW_TAG|NULL}} 82*ddbde9a4SPaul Robinson; BOTH: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x[[CU1_STROFF]]) 83*ddbde9a4SPaul Robinson; BOTH-NOT: NULL 84*ddbde9a4SPaul Robinson; BOTH: DW_TAG_variable 85*ddbde9a4SPaul Robinson; BOTH-NOT: {{DW_TAG|NULL}} 86*ddbde9a4SPaul Robinson; BOTH: DW_AT_name [DW_FORM_strx1] (indexed (0000000f) string = "glob3") 879f23426cSWolfgang Pieb; 889f23426cSWolfgang Pieb; Extract the offset of a string to verify that it is referenced in the string 899f23426cSWolfgang Pieb; offsets section. 909f23426cSWolfgang Pieb; BOTH: .debug_str contents: 919f23426cSWolfgang Pieb; BOTH-NOT: contents: 929f23426cSWolfgang Pieb; BOTH: 0x[[GLOB2OFF:[0-9a-f]+]]: "glob2" 939f23426cSWolfgang Pieb; 949f23426cSWolfgang Pieb; Check the .debug_str_offsets section header and make sure the referenced string 959f23426cSWolfgang Pieb; has the correct offset. 969f23426cSWolfgang Pieb; BOTH: .debug_str_offsets contents: 97f2b6915eSWolfgang Pieb; BOTH-NEXT: 0x00000000: Contribution size = 84, Format = DWARF32, Version = 5 989f23426cSWolfgang Pieb; BOTH-NEXT: 0x[[CU1_STROFF]]: 999f23426cSWolfgang Pieb; BOTH-NEXT: {{.*:}} 1009f23426cSWolfgang Pieb; BOTH-NEXT: {{.*:}} 1019f23426cSWolfgang Pieb; BOTH-NEXT: {{.*:}} 1029f23426cSWolfgang Pieb; BOTH-NEXT: {{.*:}} 1039f23426cSWolfgang Pieb; BOTH-NEXT: {{.*:}} 1049f23426cSWolfgang Pieb; BOTH-NEXT: {{.*:}} 1059f23426cSWolfgang Pieb; BOTH-NEXT: {{.*:}} 1069f23426cSWolfgang Pieb; BOTH-NEXT: {{.*:}} 1079f23426cSWolfgang Pieb; The string with index 9 should be "glob2" 1089f23426cSWolfgang Pieb; BOTH-NEXT: {{.*:}} [[GLOB2OFF]] 1099f23426cSWolfgang Pieb; 1109f23426cSWolfgang Pieb; ModuleID = 'test.bc' 1119f23426cSWolfgang Piebsource_filename = "llvm-link" 1129f23426cSWolfgang Pieb 1139f23426cSWolfgang Pieb@glob1 = global i32 0, align 4, !dbg !0 1149f23426cSWolfgang Pieb@glob2 = global i32 0, align 4, !dbg !11 1159f23426cSWolfgang Pieb@glob3 = global i32 0, align 4, !dbg !22 1169f23426cSWolfgang Pieb 1179f23426cSWolfgang Pieb!llvm.dbg.cu = !{!2, !13, !24} 1189f23426cSWolfgang Pieb!llvm.ident = !{!33, !33, !33} 1199f23426cSWolfgang Pieb!llvm.module.flags = !{!34, !35, !36} 1209f23426cSWolfgang Pieb 1219f23426cSWolfgang Pieb!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) 1229f23426cSWolfgang Pieb!1 = distinct !DIGlobalVariable(name: "glob1", scope: !2, file: !3, line: 2, type: !5, isLocal: false, isDefinition: true) 1239f23426cSWolfgang Pieb!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) 1249f23426cSWolfgang Pieb!3 = !DIFile(filename: "a1.cpp", directory: "/home/test", checksumkind: CSK_MD5, checksum: "2ca3eeed18355d6ebbae671eafda5aae") 1259f23426cSWolfgang Pieb!4 = !{!5} 1269f23426cSWolfgang Pieb!5 = distinct !DICompositeType(tag: DW_TAG_enumeration_type, name: "E1", file: !3, line: 1, size: 32, elements: !6, identifier: "_ZTS2E1") 1279f23426cSWolfgang Pieb!6 = !{!7, !8, !9} 1289f23426cSWolfgang Pieb!7 = !DIEnumerator(name: "a", value: 0) 1299f23426cSWolfgang Pieb!8 = !DIEnumerator(name: "b", value: 1) 1309f23426cSWolfgang Pieb!9 = !DIEnumerator(name: "c", value: 2) 1319f23426cSWolfgang Pieb!10 = !{!0} 1329f23426cSWolfgang Pieb!11 = !DIGlobalVariableExpression(var: !12, expr: !DIExpression()) 1339f23426cSWolfgang Pieb!12 = distinct !DIGlobalVariable(name: "glob2", scope: !13, file: !14, line: 2, type: !16, isLocal: false, isDefinition: true) 1349f23426cSWolfgang Pieb!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) 1359f23426cSWolfgang Pieb!14 = !DIFile(filename: "b.cpp", directory: "/home/test", checksumkind: CSK_MD5, checksum: "0e254f89617ecb6c4e5473546a99435c") 1369f23426cSWolfgang Pieb!15 = !{!16} 1379f23426cSWolfgang Pieb!16 = distinct !DICompositeType(tag: DW_TAG_enumeration_type, name: "E2", file: !14, line: 1, size: 32, elements: !17, identifier: "_ZTS2E2") 1389f23426cSWolfgang Pieb!17 = !{!18, !19, !20} 1399f23426cSWolfgang Pieb!18 = !DIEnumerator(name: "d", value: 0) 1409f23426cSWolfgang Pieb!19 = !DIEnumerator(name: "e", value: 1) 1419f23426cSWolfgang Pieb!20 = !DIEnumerator(name: "f", value: 2) 1429f23426cSWolfgang Pieb!21 = !{!11} 1439f23426cSWolfgang Pieb!22 = !DIGlobalVariableExpression(var: !23, expr: !DIExpression()) 1449f23426cSWolfgang Pieb!23 = distinct !DIGlobalVariable(name: "glob3", scope: !24, file: !25, line: 2, type: !27, isLocal: false, isDefinition: true) 1459f23426cSWolfgang Pieb!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) 1469f23426cSWolfgang Pieb!25 = !DIFile(filename: "c.cpp", directory: "/home/test", checksumkind: CSK_MD5, checksum: "7835aaaa683fa09d295adef0e934d392") 1479f23426cSWolfgang Pieb!26 = !{!27} 1489f23426cSWolfgang Pieb!27 = distinct !DICompositeType(tag: DW_TAG_enumeration_type, name: "E3", file: !25, line: 1, size: 32, elements: !28, identifier: "_ZTS2E3") 1499f23426cSWolfgang Pieb!28 = !{!29, !30, !31} 1509f23426cSWolfgang Pieb!29 = !DIEnumerator(name: "g", value: 0) 1519f23426cSWolfgang Pieb!30 = !DIEnumerator(name: "h", value: 1) 1529f23426cSWolfgang Pieb!31 = !DIEnumerator(name: "i", value: 2) 1539f23426cSWolfgang Pieb!32 = !{!22} 1549f23426cSWolfgang Pieb!33 = !{!"clang version 7.0.0 (trunk 322415)"} 1559f23426cSWolfgang Pieb!34 = !{i32 2, !"Dwarf Version", i32 5} 1569f23426cSWolfgang Pieb!35 = !{i32 2, !"Debug Info Version", i32 3} 1579f23426cSWolfgang Pieb!36 = !{i32 1, !"wchar_size", i32 4} 158