diff options
author | Eric Christopher <echristo@apple.com> | 2012-07-27 22:00:05 +0000 |
---|---|---|
committer | Eric Christopher <echristo@apple.com> | 2012-07-27 22:00:05 +0000 |
commit | c23b933d5f8be9b51a1d22e717c0311f65f87dcd (patch) | |
tree | 13941b9277e77b70fea5995ede4c4b98ca29c07e /lib/CodeGen/AsmPrinter | |
parent | c16bf79303ad8c84c5dd3c76e143cd2145539834 (diff) |
Add a DW_AT_high_pc for CUs that are a single address range. Update
all tests accordingly.
Fixes PR13351.
Patch by shinichiro hamaji!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160899 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/AsmPrinter')
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 27 | ||||
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfDebug.h | 3 |
2 files changed, 24 insertions, 6 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 649684adbf..1a8db3cf19 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -127,7 +127,8 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M) : Asm(A), MMI(Asm->MMI), FirstCU(0), AbbreviationsSet(InitAbbreviationsSetSize), SourceIdMap(DIEValueAllocator), StringPool(DIEValueAllocator), - PrevLabel(NULL) { + PrevLabel(NULL), + HasNonTextSection(false) { NextStringPoolNumber = 0; DwarfInfoSectionSym = DwarfAbbrevSectionSym = 0; @@ -561,9 +562,6 @@ CompileUnit *DwarfDebug::constructCompileUnit(const MDNode *N) { NewCU->addUInt(Die, dwarf::DW_AT_language, dwarf::DW_FORM_data2, DIUnit.getLanguage()); NewCU->addString(Die, dwarf::DW_AT_name, FN); - // 2.17.1 requires that we use DW_AT_low_pc for a single entry point - // into an entity. - NewCU->addUInt(Die, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, 0); // DW_AT_stmt_list is a offset of line number information for this // compile unit in debug_line section. if (Asm->MAI->doesDwarfUseRelocationsAcrossSections()) @@ -787,12 +785,25 @@ void DwarfDebug::endModule() { FirstCU->addUInt(ISP, dwarf::DW_AT_inline, 0, dwarf::DW_INL_inlined); } - // Emit DW_AT_containing_type attribute to connect types with their - // vtable holding type. for (DenseMap<const MDNode *, CompileUnit *>::iterator CUI = CUMap.begin(), CUE = CUMap.end(); CUI != CUE; ++CUI) { + // Emit DW_AT_containing_type attribute to connect types with their + // vtable holding type. CompileUnit *TheCU = CUI->second; TheCU->constructContainingTypeDIEs(); + + // Emit low_pc and high_pc for CU. + DIE *Die = TheCU->getCUDie(); + if (HasNonTextSection) { + // 2.17.1 requires that we use DW_AT_low_pc for a single entry point + // into an entity. + TheCU->addUInt(Die, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, 0); + } else { + TheCU->addLabel(Die, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, + Asm->GetTempSymbol("text_begin")); + TheCU->addLabel(Die, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr, + Asm->GetTempSymbol("text_end")); + } } // Standard sections final addresses. @@ -852,6 +863,7 @@ void DwarfDebug::endModule() { E = CUMap.end(); I != E; ++I) delete I->second; FirstCU = NULL; // Reset for the next Module, if any. + HasNonTextSection = false; } /// findAbstractVariable - Find abstract variable, if any, associated with Var. @@ -1220,6 +1232,9 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) { if (LScopes.empty()) return; identifyScopeMarkers(); + if (!Asm->getCurrentSection()->getKind().isText()) + HasNonTextSection = true; + FunctionBeginSym = Asm->GetTempSymbol("func_begin", Asm->getFunctionNumber()); // Assumes in correct section after the entry point. diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.h b/lib/CodeGen/AsmPrinter/DwarfDebug.h index d1d6512655..5b8f61c52e 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -307,6 +307,9 @@ class DwarfDebug { // table for the same directory as DW_at_comp_dir. StringRef CompilationDir; + // True if the current module has non text section. + bool HasNonTextSection; + private: /// assignAbbrevNumber - Define a unique number for the abbreviation. |