summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2013-12-04 21:31:26 +0000
committerDavid Blaikie <dblaikie@gmail.com>2013-12-04 21:31:26 +0000
commit3c842626ab90cda72ca0879d2fa165a26c06e3cf (patch)
tree83c869bd9ed031ef493a8145b0a8da261e7d9de9 /llvm/lib
parent8fbbb5b421b53c8af57c1f91417dbbfb90061c06 (diff)
downloadbcm5719-llvm-3c842626ab90cda72ca0879d2fa165a26c06e3cf.tar.gz
bcm5719-llvm-3c842626ab90cda72ca0879d2fa165a26c06e3cf.zip
DwarfDebug: Reduce code duplication for sec offset emission
llvm-svn: 196414
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp84
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h4
2 files changed, 32 insertions, 56 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 2e9f89e640b..3d53d3da9c1 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -724,6 +724,28 @@ unsigned DwarfDebug::getOrCreateSourceID(StringRef FileName, StringRef DirName,
return SrcId;
}
+static void addSectionLabel(AsmPrinter *Asm, Unit *U, DIE *D,
+ dwarf::Attribute A, const MCSymbol *L,
+ const MCSymbol *Sec) {
+ if (Asm->MAI->doesDwarfUseRelocationsAcrossSections())
+ U->addSectionLabel(D, A, L);
+ else
+ U->addSectionDelta(D, A, L, Sec);
+}
+
+void DwarfDebug::addGnuPubAttributes(Unit *U, DIE *D) const {
+ if (!GenerateGnuPubSections)
+ return;
+
+ addSectionLabel(Asm, U, D, dwarf::DW_AT_GNU_pubnames,
+ Asm->GetTempSymbol("gnu_pubnames", U->getUniqueID()),
+ DwarfGnuPubNamesSectionSym);
+
+ addSectionLabel(Asm, U, D, dwarf::DW_AT_GNU_pubtypes,
+ Asm->GetTempSymbol("gnu_pubtypes", U->getUniqueID()),
+ DwarfGnuPubTypesSectionSym);
+}
+
// Create new CompileUnit for the given metadata node with tag
// DW_TAG_compile_unit.
CompileUnit *DwarfDebug::constructCompileUnit(DICompileUnit DIUnit) {
@@ -783,29 +805,7 @@ CompileUnit *DwarfDebug::constructCompileUnit(DICompileUnit DIUnit) {
if (!CompilationDir.empty())
NewCU->addString(Die, dwarf::DW_AT_comp_dir, CompilationDir);
- // Flags to let the linker know we have emitted new style pubnames. Only
- // emit it here if we don't have a skeleton CU for split dwarf.
- if (GenerateGnuPubSections) {
- if (Asm->MAI->doesDwarfUseRelocationsAcrossSections())
- NewCU->addSectionLabel(
- Die, dwarf::DW_AT_GNU_pubnames,
- Asm->GetTempSymbol("gnu_pubnames", NewCU->getUniqueID()));
- else
- NewCU->addSectionDelta(
- Die, dwarf::DW_AT_GNU_pubnames,
- Asm->GetTempSymbol("gnu_pubnames", NewCU->getUniqueID()),
- DwarfGnuPubNamesSectionSym);
-
- if (Asm->MAI->doesDwarfUseRelocationsAcrossSections())
- NewCU->addSectionLabel(
- Die, dwarf::DW_AT_GNU_pubtypes,
- Asm->GetTempSymbol("gnu_pubtypes", NewCU->getUniqueID()));
- else
- NewCU->addSectionDelta(
- Die, dwarf::DW_AT_GNU_pubtypes,
- Asm->GetTempSymbol("gnu_pubtypes", NewCU->getUniqueID()),
- DwarfGnuPubTypesSectionSym);
- }
+ addGnuPubAttributes(NewCU, Die);
}
if (DIUnit.isOptimized())
@@ -3018,41 +3018,13 @@ CompileUnit *DwarfDebug::constructSkeletonCU(const CompileUnit *CU) {
if (!CompilationDir.empty())
NewCU->addLocalString(Die, dwarf::DW_AT_comp_dir, CompilationDir);
- // Flags to let the linker know we have emitted new style pubnames.
- if (GenerateGnuPubSections) {
- if (Asm->MAI->doesDwarfUseRelocationsAcrossSections())
- NewCU->addSectionLabel(
- Die, dwarf::DW_AT_GNU_pubnames,
- Asm->GetTempSymbol("gnu_pubnames", NewCU->getUniqueID()));
- else
- NewCU->addSectionDelta(
- Die, dwarf::DW_AT_GNU_pubnames,
- Asm->GetTempSymbol("gnu_pubnames", NewCU->getUniqueID()),
- DwarfGnuPubNamesSectionSym);
-
- if (Asm->MAI->doesDwarfUseRelocationsAcrossSections())
- NewCU->addSectionLabel(
- Die, dwarf::DW_AT_GNU_pubtypes,
- Asm->GetTempSymbol("gnu_pubtypes", NewCU->getUniqueID()));
- else
- NewCU->addSectionDelta(
- Die, dwarf::DW_AT_GNU_pubtypes,
- Asm->GetTempSymbol("gnu_pubtypes", NewCU->getUniqueID()),
- DwarfGnuPubTypesSectionSym);
- }
+ addGnuPubAttributes(NewCU, Die);
// Attribute if we've emitted any ranges and their location for the compile unit.
- if (!CU->getRangeLists().empty()) {
- if (Asm->MAI->doesDwarfUseRelocationsAcrossSections())
- NewCU->addSectionLabel(
- Die, dwarf::DW_AT_GNU_ranges_base,
- Asm->GetTempSymbol("gnu_ranges", NewCU->getUniqueID()));
- else
- NewCU->addSectionDelta(
- Die, dwarf::DW_AT_GNU_ranges_base,
- Asm->GetTempSymbol("gnu_ranges", NewCU->getUniqueID()),
- DwarfDebugRangeSectionSym);
- }
+ if (!CU->getRangeLists().empty())
+ addSectionLabel(Asm, NewCU, Die, dwarf::DW_AT_GNU_ranges_base,
+ Asm->GetTempSymbol("gnu_ranges", NewCU->getUniqueID()),
+ DwarfDebugRangeSectionSym);
SkeletonHolder.addUnit(NewCU);
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
index c68e37e7ec5..92152507254 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
@@ -627,6 +627,10 @@ class DwarfDebug : public AsmPrinterHandler {
/// \brief Emit the debug str dwo section.
void emitDebugStrDWO();
+ /// Flags to let the linker know we have emitted new style pubnames. Only
+ /// emit it here if we don't have a skeleton CU for split dwarf.
+ void addGnuPubAttributes(Unit *U, DIE *D) const;
+
/// \brief Create new CompileUnit for the given metadata node with tag
/// DW_TAG_compile_unit.
CompileUnit *constructCompileUnit(DICompileUnit DIUnit);
OpenPOWER on IntegriCloud