Index: lib/CodeGen/AsmPrinter/DIE.cpp =================================================================== --- lib/CodeGen/AsmPrinter/DIE.cpp +++ lib/CodeGen/AsmPrinter/DIE.cpp @@ -338,6 +338,7 @@ /// unsigned DIEDelta::SizeOf(AsmPrinter *AP, dwarf::Form Form) const { if (Form == dwarf::DW_FORM_data4) return 4; + if (Form == dwarf::DW_FORM_sec_offset) return 4; if (Form == dwarf::DW_FORM_strp) return 4; return AP->getDataLayout().getPointerSize(); } Index: lib/CodeGen/AsmPrinter/DwarfCompileUnit.h =================================================================== --- lib/CodeGen/AsmPrinter/DwarfCompileUnit.h +++ lib/CodeGen/AsmPrinter/DwarfCompileUnit.h @@ -209,6 +209,14 @@ void addLabel(DIEBlock *Die, dwarf::Form Form, const MCSymbol *Label); + /// addLabel - Add a Dwarf label attribute data and value. + /// + void addLabel(DIE *Die, dwarf::Attribute Attribute, const MCSymbol *Label); + + /// addOffset - Add an offset into a section attribute data and value. + /// + void addOffset(DIE *Die, dwarf::Attribute Attribute, uint64_t Integer); + /// addLabelAddress - Add a dwarf label attribute data and value using /// either DW_FORM_addr or DW_FORM_GNU_addr_index. /// @@ -221,7 +229,7 @@ /// addDelta - Add a label delta attribute data and value. /// - void addDelta(DIE *Die, dwarf::Attribute Attribute, dwarf::Form Form, const MCSymbol *Hi, + void addDelta(DIE *Die, dwarf::Attribute Attribute, const MCSymbol *Hi, const MCSymbol *Lo); /// addDIEEntry - Add a DIE attribute data and value. Index: lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp =================================================================== --- lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -227,6 +227,26 @@ addLabel(Die, (dwarf::Attribute)0, Form, Label); } +/// addLabel - Add a Dwarf label attribute data and value. +/// +void CompileUnit::addLabel(DIE *Die, dwarf::Attribute Attribute, + const MCSymbol *Label) { + if (DD->getDwarfVersion() >= 4) + addLabel(Die, Attribute, dwarf::DW_FORM_sec_offset, Label); + else + addLabel(Die, Attribute, dwarf::DW_FORM_data4, Label); +} + +/// addOffset - Add an offset into a section attribute data and value. +/// +void CompileUnit::addOffset(DIE *Die, dwarf::Attribute Attribute, + uint64_t Integer) { + if (DD->getDwarfVersion() >= 4) + addUInt(Die, Attribute, dwarf::DW_FORM_sec_offset, Integer); + else + addUInt(Die, Attribute, dwarf::DW_FORM_data4, Integer); +} + /// addLabelAddress - Add a dwarf label attribute data and value using /// DW_FORM_addr or DW_FORM_GNU_addr_index. /// @@ -267,10 +287,12 @@ /// addDelta - Add a label delta attribute data and value. /// void CompileUnit::addDelta(DIE *Die, dwarf::Attribute Attribute, - dwarf::Form Form, const MCSymbol *Hi, - const MCSymbol *Lo) { + const MCSymbol *Hi, const MCSymbol *Lo) { DIEValue *Value = new (DIEValueAllocator) DIEDelta(Hi, Lo); - Die->addValue(Attribute, Form, Value); + if (DD->getDwarfVersion() >= 4) + Die->addValue(Attribute, dwarf::DW_FORM_sec_offset, Value); + else + Die->addValue(Attribute, dwarf::DW_FORM_data4, Value); } /// addDIEEntry - Add a DIE attribute data and value. @@ -1777,7 +1799,7 @@ unsigned Offset = DV->getDotDebugLocOffset(); if (Offset != ~0U) { - addLabel(VariableDie, dwarf::DW_AT_location, dwarf::DW_FORM_data4, + addLabel(VariableDie, dwarf::DW_AT_location, Asm->GetTempSymbol("debug_loc", Offset)); DV->setDIE(VariableDie); return VariableDie; Index: lib/CodeGen/AsmPrinter/DwarfDebug.cpp =================================================================== --- lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -105,6 +105,11 @@ clEnumVal(Disable, "Disabled"), clEnumValEnd), cl::init(Default)); +static cl::opt +DwarfVersionNumber("dwarf-version", cl::Hidden, + cl::desc("Generate DWARF for dwarf version."), + cl::init(0)); + static const char *const DWARFGroupName = "DWARF Emission"; static const char *const DbgTimerName = "DWARF Debug Writer"; @@ -178,6 +183,15 @@ return cast(Val)->getZExtValue(); } +/// Return Dwarf Version from command line options, or 0 if no +/// valid option specified. +static unsigned getDwarfVersionFromOption() { + if (DwarfVersionNumber >= 2 && DwarfVersionNumber <= 4) { + return DwarfVersionNumber; + } + return 0; +} + DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M) : Asm(A), MMI(Asm->MMI), FirstCU(0), AbbreviationsSet(InitAbbreviationsSetSize), @@ -215,7 +229,9 @@ else HasDwarfPubSections = DwarfPubSections == Enable; - DwarfVersion = getDwarfVersionFromModule(MMI->getModule()); + DwarfVersion = getDwarfVersionFromOption(); + if (!DwarfVersion) + DwarfVersion = getDwarfVersionFromModule(MMI->getModule()); { NamedRegionTimer T(DbgTimerName, DWARFGroupName, TimePassesIsEnabled); @@ -472,7 +488,7 @@ // .debug_range section has not been laid out yet. Emit offset in // .debug_range as a uint, size 4, for now. emitDIE will handle // DW_AT_ranges appropriately. - TheCU->addUInt(ScopeDIE, dwarf::DW_AT_ranges, dwarf::DW_FORM_data4, + TheCU->addOffset(ScopeDIE, dwarf::DW_AT_ranges, DebugRangeSymbols.size() * Asm->getDataLayout().getPointerSize()); for (SmallVectorImpl::const_iterator RI = Ranges.begin(), @@ -527,7 +543,7 @@ // .debug_range section has not been laid out yet. Emit offset in // .debug_range as a uint, size 4, for now. emitDIE will handle // DW_AT_ranges appropriately. - TheCU->addUInt(ScopeDIE, dwarf::DW_AT_ranges, dwarf::DW_FORM_data4, + TheCU->addOffset(ScopeDIE, dwarf::DW_AT_ranges, DebugRangeSymbols.size() * Asm->getDataLayout().getPointerSize()); for (SmallVectorImpl::const_iterator RI = Ranges.begin(), @@ -763,13 +779,13 @@ // The line table entries are not always emitted in assembly, so it // is not okay to use line_table_start here. if (Asm->MAI->doesDwarfUseRelocationsAcrossSections()) - NewCU->addLabel(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_sec_offset, + NewCU->addLabel(Die, dwarf::DW_AT_stmt_list, UseTheFirstCU ? Asm->GetTempSymbol("section_line") : LineTableStartSym); else if (UseTheFirstCU) - NewCU->addUInt(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_data4, 0); + NewCU->addOffset(Die, dwarf::DW_AT_stmt_list, 0); else - NewCU->addDelta(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_data4, + NewCU->addDelta(Die, dwarf::DW_AT_stmt_list, LineTableStartSym, DwarfLineSectionSym); // If we're using split dwarf the compilation dir is going to be in the @@ -782,22 +798,20 @@ if (GenerateGnuPubSections) { if (Asm->MAI->doesDwarfUseRelocationsAcrossSections()) NewCU->addLabel(Die, dwarf::DW_AT_GNU_pubnames, - dwarf::DW_FORM_sec_offset, Asm->GetTempSymbol("gnu_pubnames", NewCU->getUniqueID())); else - NewCU->addDelta(Die, dwarf::DW_AT_GNU_pubnames, dwarf::DW_FORM_data4, + NewCU->addDelta(Die, dwarf::DW_AT_GNU_pubnames, Asm->GetTempSymbol("gnu_pubnames", NewCU->getUniqueID()), DwarfGnuPubNamesSectionSym); if (Asm->MAI->doesDwarfUseRelocationsAcrossSections()) NewCU->addLabel(Die, dwarf::DW_AT_GNU_pubtypes, - dwarf::DW_FORM_sec_offset, Asm->GetTempSymbol("gnu_pubtypes", NewCU->getUniqueID())); else - NewCU->addDelta(Die, dwarf::DW_AT_GNU_pubtypes, dwarf::DW_FORM_data4, + NewCU->addDelta(Die, dwarf::DW_AT_GNU_pubtypes, Asm->GetTempSymbol("gnu_pubtypes", NewCU->getUniqueID()), DwarfGnuPubTypesSectionSym); @@ -2962,11 +2976,10 @@ // Relocate to the beginning of the addr_base section, else 0 for the // beginning of the one for this compile unit. if (Asm->MAI->doesDwarfUseRelocationsAcrossSections()) - NewCU->addLabel(Die, dwarf::DW_AT_GNU_addr_base, dwarf::DW_FORM_sec_offset, + NewCU->addLabel(Die, dwarf::DW_AT_GNU_addr_base, DwarfAddrSectionSym); else - NewCU->addUInt(Die, dwarf::DW_AT_GNU_addr_base, - dwarf::DW_FORM_sec_offset, 0); + NewCU->addOffset(Die, dwarf::DW_AT_GNU_addr_base, 0); // 2.17.1 requires that we use DW_AT_low_pc for a single entry point // into an entity. We're using 0, or a NULL label for this. @@ -2976,10 +2989,10 @@ // compile unit in debug_line section. // FIXME: Should handle multiple compile units. if (Asm->MAI->doesDwarfUseRelocationsAcrossSections()) - NewCU->addLabel(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_sec_offset, + NewCU->addLabel(Die, dwarf::DW_AT_stmt_list, DwarfLineSectionSym); else - NewCU->addUInt(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_sec_offset, 0); + NewCU->addOffset(Die, dwarf::DW_AT_stmt_list, 0); if (!CompilationDir.empty()) NewCU->addLocalString(Die, dwarf::DW_AT_comp_dir, CompilationDir); @@ -2987,18 +3000,18 @@ // Flags to let the linker know we have emitted new style pubnames. if (GenerateGnuPubSections) { if (Asm->MAI->doesDwarfUseRelocationsAcrossSections()) - NewCU->addLabel(Die, dwarf::DW_AT_GNU_pubnames, dwarf::DW_FORM_sec_offset, + NewCU->addLabel(Die, dwarf::DW_AT_GNU_pubnames, Asm->GetTempSymbol("gnu_pubnames", NewCU->getUniqueID())); else - NewCU->addDelta(Die, dwarf::DW_AT_GNU_pubnames, dwarf::DW_FORM_data4, + NewCU->addDelta(Die, dwarf::DW_AT_GNU_pubnames, Asm->GetTempSymbol("gnu_pubnames", NewCU->getUniqueID()), DwarfGnuPubNamesSectionSym); if (Asm->MAI->doesDwarfUseRelocationsAcrossSections()) - NewCU->addLabel(Die, dwarf::DW_AT_GNU_pubtypes, dwarf::DW_FORM_sec_offset, + NewCU->addLabel(Die, dwarf::DW_AT_GNU_pubtypes, Asm->GetTempSymbol("gnu_pubtypes", NewCU->getUniqueID())); else - NewCU->addDelta(Die, dwarf::DW_AT_GNU_pubtypes, dwarf::DW_FORM_data4, + NewCU->addDelta(Die, dwarf::DW_AT_GNU_pubtypes, Asm->GetTempSymbol("gnu_pubtypes", NewCU->getUniqueID()), DwarfGnuPubTypesSectionSym); } @@ -3007,7 +3020,7 @@ if (DebugRangeSymbols.size()) { if (Asm->MAI->doesDwarfUseRelocationsAcrossSections()) NewCU->addLabel(Die, dwarf::DW_AT_GNU_ranges_base, - dwarf::DW_FORM_sec_offset, DwarfDebugRangeSectionSym); + DwarfDebugRangeSectionSym); else NewCU->addUInt(Die, dwarf::DW_AT_GNU_ranges_base, dwarf::DW_FORM_data4, 0); Index: test/DebugInfo/X86/DW_AT_stmt_list_sec_offset.ll =================================================================== --- test/DebugInfo/X86/DW_AT_stmt_list_sec_offset.ll +++ test/DebugInfo/X86/DW_AT_stmt_list_sec_offset.ll @@ -1,7 +1,10 @@ ; RUN: llc -mtriple=i686-w64-mingw32 -o %t -filetype=obj %s ; RUN: llvm-dwarfdump -debug-dump=all %t | FileCheck %s +; RUN: llc -mtriple=i686-w64-mingw32 -o %t -filetype=obj -dwarf-version=3 %s +; RUN: llvm-dwarfdump -debug-dump=all %t | FileCheck %s -check-prefix=DWARF3 ; CHECK: DW_AT_stmt_list [DW_FORM_sec_offset] +; DWARF3: DW_AT_stmt_list [DW_FORM_data4] ; ; generated from: ; clang -g -S -emit-llvm test.c -o test.ll @@ -36,5 +39,5 @@ !6 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !7, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] !7 = metadata !{metadata !8} !8 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed] -!9 = metadata !{i32 2, metadata !"Dwarf Version", i32 3} +!9 = metadata !{i32 2, metadata !"Dwarf Version", i32 4} !10 = metadata !{i32 3, i32 0, metadata !4, null} Index: test/DebugInfo/X86/block-capture.ll =================================================================== --- test/DebugInfo/X86/block-capture.ll +++ test/DebugInfo/X86/block-capture.ll @@ -1,11 +1,18 @@ ; RUN: llc -mtriple=x86_64-apple-darwin %s -o %t -filetype=obj ; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s +; RUN: llc -mtriple=x86_64-apple-darwin %s -o %t -filetype=obj -dwarf-version=3 +; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s -check-prefix=DWARF3 ; Checks that we emit debug info for the block variable declare. ; CHECK: DW_TAG_subprogram [3] ; CHECK: DW_TAG_variable [5] ; CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[{{.*}}] = "block") -; CHECK: DW_AT_location [DW_FORM_data4] ({{.*}}) +; CHECK: DW_AT_location [DW_FORM_sec_offset] ({{.*}}) + +; DWARF3: DW_TAG_subprogram [3] +; DWARF3: DW_TAG_variable [5] +; DWARF3: DW_AT_name [DW_FORM_strp] ( .debug_str[{{.*}}] = "block") +; DWARF3: DW_AT_location [DW_FORM_data4] ({{.*}}) %struct.__block_descriptor = type { i64, i64 } %struct.__block_literal_generic = type { i8*, i32, i32, i8*, %struct.__block_descriptor* } Index: test/DebugInfo/X86/fission-cu.ll =================================================================== --- test/DebugInfo/X86/fission-cu.ll +++ test/DebugInfo/X86/fission-cu.ll @@ -1,5 +1,7 @@ ; RUN: llc -split-dwarf=Enable -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t ; RUN: llvm-dwarfdump -debug-dump=all %t | FileCheck %s +; RUN: llc -split-dwarf=Enable -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t -dwarf-version=3 +; RUN: llvm-dwarfdump -debug-dump=all %t | FileCheck %s --check-prefix=DWARF3 ; RUN: llvm-readobj --relocations %t | FileCheck --check-prefix=OBJ %s @a = common global i32 0, align 4 @@ -100,6 +102,87 @@ ; CHECK: 0x00000008: 0000003b ; CHECK: 0x0000000c: 0000003d +; DWARF3: .debug_abbrev contents: +; DWARF3: Abbrev table for offset: 0x00000000 +; DWARF3: [1] DW_TAG_compile_unit DW_CHILDREN_no +; DWARF3: DW_AT_GNU_dwo_name DW_FORM_strp +; DWARF3: DW_AT_GNU_addr_base DW_FORM_data4 +; DWARF3: DW_AT_low_pc DW_FORM_addr +; DWARF3: DW_AT_stmt_list DW_FORM_data4 +; DWARF3: DW_AT_comp_dir DW_FORM_strp +; DWARF3: DW_AT_GNU_dwo_id DW_FORM_data8 + +; DWARF3: .debug_info contents: +; DWARF3: DW_TAG_compile_unit +; DWARF3: DW_AT_GNU_dwo_name [DW_FORM_strp] ( .debug_str[0x00000000] = "baz.dwo") +; DWARF3: DW_AT_GNU_addr_base [DW_FORM_data4] (0x00000000) +; DWARF3: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000) +; DWARF3: DW_AT_stmt_list [DW_FORM_data4] (0x00000000) +; DWARF3: DW_AT_comp_dir [DW_FORM_strp] ( .debug_str[0x00000008] = "/usr/local/google/home/echristo/tmp") +; DWARF3: DW_AT_GNU_dwo_id [DW_FORM_data8] (0x0000000000000000) + +; DWARF3: .debug_str contents: +; DWARF3: 0x00000000: "baz.dwo" +; DWARF3: 0x00000008: "/usr/local/google/home/echristo/tmp" + +; Check that we're using the right forms. +; DWARF3: .debug_abbrev.dwo contents: +; DWARF3: Abbrev table for offset: 0x00000000 +; DWARF3: [1] DW_TAG_compile_unit DW_CHILDREN_yes +; DWARF3: DW_AT_producer DW_FORM_GNU_str_index +; DWARF3: DW_AT_language DW_FORM_data2 +; DWARF3: DW_AT_name DW_FORM_GNU_str_index +; DWARF3-NOT: DW_AT_low_pc +; DWARF3-NOT: DW_AT_stmt_list +; DWARF3-NOT: DW_AT_comp_dir +; DWARF3: DW_AT_GNU_dwo_id DW_FORM_data8 + +; DWARF3: [2] DW_TAG_variable DW_CHILDREN_no +; DWARF3: DW_AT_name DW_FORM_GNU_str_index +; DWARF3: DW_AT_type DW_FORM_ref4 +; DWARF3: DW_AT_external DW_FORM_flag +; DWARF3: DW_AT_decl_file DW_FORM_data1 +; DWARF3: DW_AT_decl_line DW_FORM_data1 +; DWARF3: DW_AT_location DW_FORM_block1 + +; DWARF3: [3] DW_TAG_base_type DW_CHILDREN_no +; DWARF3: DW_AT_name DW_FORM_GNU_str_index +; DWARF3: DW_AT_encoding DW_FORM_data1 +; DWARF3: DW_AT_byte_size DW_FORM_data1 + +; Check that the rest of the compile units have information. +; DWARF3: .debug_info.dwo contents: +; DWARF3: DW_TAG_compile_unit +; DWARF3: DW_AT_producer [DW_FORM_GNU_str_index] ( indexed (00000000) string = "clang version 3.3 (trunk 169021) (llvm/trunk 169020)") +; DWARF3: DW_AT_language [DW_FORM_data2] (0x000c) +; DWARF3: DW_AT_name [DW_FORM_GNU_str_index] ( indexed (00000001) string = "baz.c") +; DWARF3-NOT: DW_AT_low_pc +; DWARF3-NOT: DW_AT_stmt_list +; DWARF3-NOT: DW_AT_comp_dir +; DWARF3: DW_AT_GNU_dwo_id [DW_FORM_data8] (0x0000000000000000) +; DWARF3: DW_TAG_variable +; DWARF3: DW_AT_name [DW_FORM_GNU_str_index] ( indexed (00000002) string = "a") +; DWARF3: DW_AT_type [DW_FORM_ref4] (cu + 0x{{[0-9a-f]*}} => {[[TYPE:0x[0-9a-f]*]]}) +; DWARF3: DW_AT_external [DW_FORM_flag] (0x01) +; DWARF3: DW_AT_decl_file [DW_FORM_data1] (0x01) +; DWARF3: DW_AT_decl_line [DW_FORM_data1] (0x01) +; DWARF3: DW_AT_location [DW_FORM_block1] (<0x02> fb 00 ) +; DWARF3: [[TYPE]]: DW_TAG_base_type +; DWARF3: DW_AT_name [DW_FORM_GNU_str_index] ( indexed (00000003) string = "int") + + +; DWARF3: .debug_str.dwo contents: +; DWARF3: 0x00000000: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)" +; DWARF3: 0x00000035: "baz.c" +; DWARF3: 0x0000003b: "a" +; DWARF3: 0x0000003d: "int" + +; DWARF3: .debug_str_offsets.dwo contents: +; DWARF3: 0x00000000: 00000000 +; DWARF3: 0x00000004: 00000035 +; DWARF3: 0x00000008: 0000003b +; DWARF3: 0x0000000c: 0000003d + ; Object file checks ; For x86-64-linux we should have this set of relocations for the debug info section ; Index: test/DebugInfo/X86/gnu-public-names.ll =================================================================== --- test/DebugInfo/X86/gnu-public-names.ll +++ test/DebugInfo/X86/gnu-public-names.ll @@ -1,5 +1,6 @@ ; RUN: llc -mtriple=x86_64-pc-linux-gnu -generate-gnu-dwarf-pub-sections < %s | FileCheck -check-prefix=ASM %s ; RUN: llc -mtriple=x86_64-pc-linux-gnu -generate-gnu-dwarf-pub-sections -filetype=obj < %s | llvm-dwarfdump - | FileCheck %s +; RUN: llc -mtriple=x86_64-pc-linux-gnu -generate-gnu-dwarf-pub-sections -filetype=obj -dwarf-version=3 < %s | llvm-dwarfdump - | FileCheck %s -check-prefix=DWARF3 ; ModuleID = 'dwarf-public-names.cpp' ; ; Generated from: @@ -123,6 +124,85 @@ ; CHECK-DAG: [[D]] EXTERNAL TYPE "ns::D" ; CHECK-DAG: [[INT]] STATIC TYPE "int" +; DWARF3: .debug_info contents: +; DWARF3: DW_AT_GNU_pubnames [DW_FORM_data4] (0x00000000) +; DWARF3: DW_AT_GNU_pubtypes [DW_FORM_data4] (0x00000000) + +; DWARF3: [[C:[0-9a-f]+]]: DW_TAG_structure_type +; DWARF3-NEXT: DW_AT_name {{.*}} "C" + +; DWARF3: [[STATIC_MEM_DECL:[0-9a-f]+]]: DW_TAG_member +; DWARF3-NEXT: DW_AT_name {{.*}} "static_member_variable" + +; DWARF3: [[MEM_FUNC_DECL:[0-9a-f]+]]: DW_TAG_subprogram +; DWARF3-NEXT: DW_AT_MIPS_linkage_name +; DWARF3-NEXT: DW_AT_name {{.*}} "member_function" + +; DWARF3: [[STATIC_MEM_FUNC_DECL:[0-9a-f]+]]: DW_TAG_subprogram +; DWARF3-NEXT: DW_AT_MIPS_linkage_name +; DWARF3-NEXT: DW_AT_name {{.*}} "static_member_function" + +; DWARF3: [[INT:[0-9a-f]+]]: DW_TAG_base_type +; DWARF3-NEXT: DW_AT_name {{.*}} "int" + +; DWARF3: [[STATIC_MEM_VAR:[0-9a-f]+]]: DW_TAG_variable +; DWARF3-NEXT: DW_AT_specification {{.*}}[[STATIC_MEM_DECL]] + +; DWARF3: [[GLOB_VAR:[0-9a-f]+]]: DW_TAG_variable +; DWARF3-NEXT: DW_AT_name {{.*}} "global_variable" + +; DWARF3: [[NS:[0-9a-f]+]]: DW_TAG_namespace +; DWARF3-NEXT: DW_AT_name {{.*}} "ns" + +; DWARF3: [[GLOB_NS_VAR_DECL:[0-9a-f]+]]: DW_TAG_variable +; DWARF3-NEXT: DW_AT_name {{.*}} "global_namespace_variable" + +; DWARF3: [[D_VAR_DECL:[0-9a-f]+]]: DW_TAG_variable +; DWARF3-NEXT: DW_AT_name {{.*}} "d" + +; DWARF3: [[D:[0-9a-f]+]]: DW_TAG_structure_type +; DWARF3-NEXT: DW_AT_name {{.*}} "D" + +; DWARF3: [[GLOB_NS_FUNC:[0-9a-f]+]]: DW_TAG_subprogram +; DWARF3-NEXT: DW_AT_MIPS_linkage_name +; DWARF3-NEXT: DW_AT_name {{.*}} "global_namespace_function" + +; DWARF3: [[GLOB_NS_VAR:[0-9a-f]+]]: DW_TAG_variable +; DWARF3-NEXT: DW_AT_specification {{.*}}[[GLOB_NS_VAR_DECL]] + +; DWARF3: [[D_VAR:[0-9a-f]+]]: DW_TAG_variable +; DWARF3-NEXT: DW_AT_specification {{.*}}[[D_VAR_DECL]] + +; DWARF3: [[MEM_FUNC:[0-9a-f]+]]: DW_TAG_subprogram +; DWARF3-NEXT: DW_AT_specification {{.*}}[[MEM_FUNC_DECL]] + +; DWARF3: [[STATIC_MEM_FUNC:[0-9a-f]+]]: DW_TAG_subprogram +; DWARF3-NEXT: DW_AT_specification {{.*}}[[STATIC_MEM_FUNC_DECL]] + +; DWARF3: [[GLOBAL_FUNC:[0-9a-f]+]]: DW_TAG_subprogram +; DWARF3-NEXT: DW_AT_MIPS_linkage_name +; DWARF3-NEXT: DW_AT_name {{.*}} "global_function" + +; DWARF3-LABEL: .debug_gnu_pubnames contents: +; DWARF3-NEXT: length = 0x000000e7 version = 0x0002 unit_offset = 0x00000000 unit_size = 0x0000018b +; DWARF3-NEXT: Offset Linkage Kind Name +; DWARF3-DAG: [[GLOBAL_FUNC]] EXTERNAL FUNCTION "global_function" +; DWARF3-DAG: [[NS]] EXTERNAL TYPE "ns" +; DWARF3-DAG: [[MEM_FUNC]] EXTERNAL FUNCTION "C::member_function" +; DWARF3-DAG: [[GLOB_VAR]] EXTERNAL VARIABLE "global_variable" +; DWARF3-DAG: [[GLOB_NS_VAR]] EXTERNAL VARIABLE "ns::global_namespace_variable" +; DWARF3-DAG: [[GLOB_NS_FUNC]] EXTERNAL FUNCTION "ns::global_namespace_function" +; DWARF3-DAG: [[D_VAR]] EXTERNAL VARIABLE "ns::d" +; DWARF3-DAG: [[STATIC_MEM_VAR]] EXTERNAL VARIABLE "C::static_member_variable" +; DWARF3-DAG: [[STATIC_MEM_FUNC]] EXTERNAL FUNCTION "C::static_member_function" + + +; DWARF3-LABEL: debug_gnu_pubtypes contents: +; DWARF3: Offset Linkage Kind Name +; DWARF3-DAG: [[C]] EXTERNAL TYPE "C" +; DWARF3-DAG: [[D]] EXTERNAL TYPE "ns::D" +; DWARF3-DAG: [[INT]] STATIC TYPE "int" + %struct.C = type { i8 } %"struct.ns::D" = type { i32 } Index: test/DebugInfo/X86/op_deref.ll =================================================================== --- test/DebugInfo/X86/op_deref.ll +++ test/DebugInfo/X86/op_deref.ll @@ -1,10 +1,17 @@ ; RUN: llc -O0 -mtriple=x86_64-apple-darwin %s -o %t -filetype=obj ; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s -check-prefix=DW-CHECK +; RUN: llc -O0 -mtriple=x86_64-apple-darwin %s -o %t -filetype=obj -dwarf-version=3 +; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s -check-prefix=DWARF3 ; DW-CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000067] = "vla") ; FIXME: The location here needs to be fixed, but llvm-dwarfdump doesn't handle ; DW_AT_location lists yet. -; DW-CHECK: DW_AT_location [DW_FORM_data4] (0x00000000) +; DW-CHECK: DW_AT_location [DW_FORM_sec_offset] (0x00000000) + +; DWARF3: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000067] = "vla") +; FIXME: The location here needs to be fixed, but llvm-dwarfdump doesn't handle +; DW_AT_location lists yet. +; DWARF3: DW_AT_location [DW_FORM_data4] (0x00000000) ; Unfortunately llvm-dwarfdump can't unparse a list of DW_AT_locations ; right now, so we check the asm output: Index: test/DebugInfo/X86/stmt-list-multiple-compile-units.ll =================================================================== --- test/DebugInfo/X86/stmt-list-multiple-compile-units.ll +++ test/DebugInfo/X86/stmt-list-multiple-compile-units.ll @@ -1,16 +1,18 @@ ; RUN: llc -O0 %s -mtriple=x86_64-apple-darwin -filetype=obj -o %t ; RUN: llvm-dwarfdump %t | FileCheck %s +; RUN: llc -O0 %s -mtriple=x86_64-apple-darwin -filetype=obj -o %t -dwarf-version=3 +; RUN: llvm-dwarfdump %t | FileCheck %s -check-prefix=DWARF3 ; RUN: llc < %s -O0 -mtriple=x86_64-apple-macosx10.7 | FileCheck %s -check-prefix=ASM ; rdar://13067005 ; CHECK: .debug_info contents: ; CHECK: DW_TAG_compile_unit ; CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000) -; CHECK: DW_AT_stmt_list [DW_FORM_data4] (0x00000000) +; CHECK: DW_AT_stmt_list [DW_FORM_sec_offset] (0x00000000) ; CHECK: DW_TAG_compile_unit ; CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000) -; CHECK: DW_AT_stmt_list [DW_FORM_data4] (0x0000003c) +; CHECK: DW_AT_stmt_list [DW_FORM_sec_offset] (0x0000003c) ; CHECK: .debug_line contents: ; CHECK-NEXT: Line table prologue: @@ -21,6 +23,24 @@ ; CHECK: file_names[ 1] 0 0x00000000 0x00000000 simple2.c ; CHECK-NOT: file_names +; DWARF3: .debug_info contents: +; DWARF3: DW_TAG_compile_unit +; DWARF3: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000) +; DWARF3: DW_AT_stmt_list [DW_FORM_data4] (0x00000000) + +; DWARF3: DW_TAG_compile_unit +; DWARF3: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000) +; DWARF3: DW_AT_stmt_list [DW_FORM_data4] (0x0000003c) + +; DWARF3: .debug_line contents: +; DWARF3-NEXT: Line table prologue: +; DWARF3-NEXT: total_length: 0x00000038 +; DWARF3: file_names[ 1] 0 0x00000000 0x00000000 simple.c +; DWARF3: Line table prologue: +; DWARF3-NEXT: total_length: 0x00000039 +; DWARF3: file_names[ 1] 0 0x00000000 0x00000000 simple2.c +; DWARF3-NOT: file_names + ; PR15408 ; ASM: L__DWARF__debug_info_begin0: ; ASM: .long 0 ## DW_AT_stmt_list