summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp14
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h8
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp16
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h16
4 files changed, 44 insertions, 10 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 77765e12f81..ab03753227d 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -1060,6 +1060,7 @@ void DwarfDebug::endModule() {
emitDebugStrDWO();
emitDebugInfoDWO();
emitDebugAbbrevDWO();
+ emitDebugLineDWO();
// Emit DWO addresses.
InfoHolder.emitAddresses(Asm->getObjFileLowering().getDwarfAddrSection());
}
@@ -2658,7 +2659,6 @@ DwarfTypeUnit *DwarfDebug::constructSkeletonTU(DwarfTypeUnit *TU) {
NewTU->setType(NULL);
NewTU->initSection(
Asm->getObjFileLowering().getDwarfTypesSection(TU->getTypeSignature()));
- CU.applyStmtList(*Die);
initSkeletonUnit(TU, Die, NewTU);
return NewTU;
@@ -2680,6 +2680,13 @@ void DwarfDebug::emitDebugAbbrevDWO() {
InfoHolder.emitAbbrevs(Asm->getObjFileLowering().getDwarfAbbrevDWOSection());
}
+void DwarfDebug::emitDebugLineDWO() {
+ assert(useSplitDwarf() && "No split dwarf?");
+ Asm->OutStreamer.SwitchSection(
+ Asm->getObjFileLowering().getDwarfLineDWOSection());
+ Asm->OutStreamer.EmitLabel(SplitTypeUnitFileTable.Emit(&Asm->OutStreamer).second);
+}
+
// Emit the .debug_str.dwo section for separated dwarf. This contains the
// string section and is identical in format to traditional .debug_str
// sections.
@@ -2708,8 +2715,9 @@ void DwarfDebug::addDwarfTypeUnitType(DwarfCompileUnit &CU,
}
DIE *UnitDie = new DIE(dwarf::DW_TAG_type_unit);
- DwarfTypeUnit *NewTU = new DwarfTypeUnit(InfoHolder.getUnits().size(),
- UnitDie, CU, Asm, this, &InfoHolder);
+ DwarfTypeUnit *NewTU = new DwarfTypeUnit(
+ InfoHolder.getUnits().size(), UnitDie, CU, Asm, this, &InfoHolder,
+ useSplitDwarf() ? &SplitTypeUnitFileTable : nullptr);
TU = NewTU;
InfoHolder.addUnit(NewTU);
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
index 71ff75d640a..4756509d094 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
@@ -27,6 +27,7 @@
#include "llvm/IR/DebugInfo.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/MC/MachineLocation.h"
+#include "llvm/MC/MCDwarf.h"
#include "llvm/Support/Allocator.h"
namespace llvm {
@@ -486,6 +487,10 @@ class DwarfDebug : public AsmPrinterHandler {
// Holder for the skeleton information.
DwarfFile SkeletonHolder;
+ // Store file names for type units under fission in a line table header that
+ // will be emitted into debug_line.dwo.
+ MCDwarfLineTableHeader SplitTypeUnitFileTable;
+
void addScopeVariable(LexicalScope *LS, DbgVariable *Var);
const SmallVectorImpl<DwarfUnit *> &getUnits() {
@@ -621,6 +626,9 @@ class DwarfDebug : public AsmPrinterHandler {
/// \brief Emit the debug abbrev dwo section.
void emitDebugAbbrevDWO();
+ /// \brief Emit the debug line dwo section.
+ void emitDebugLineDWO();
+
/// \brief Emit the debug str dwo section.
void emitDebugStrDWO();
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
index 9b7e38f9bd4..2a74d0552fe 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -56,8 +56,13 @@ DwarfCompileUnit::DwarfCompileUnit(unsigned UID, DIE *D, DICompileUnit Node,
}
DwarfTypeUnit::DwarfTypeUnit(unsigned UID, DIE *D, DwarfCompileUnit &CU,
- AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU)
- : DwarfUnit(UID, D, CU.getCUNode(), A, DW, DWU), CU(CU) {}
+ AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU,
+ MCDwarfLineTableHeader *SplitLineTable)
+ : DwarfUnit(UID, D, CU.getCUNode(), A, DW, DWU), CU(CU),
+ SplitLineTable(SplitLineTable) {
+ if (SplitLineTable)
+ addSectionOffset(UnitDie.get(), dwarf::DW_AT_stmt_list, 0);
+}
/// ~Unit - Destructor for compile unit.
DwarfUnit::~DwarfUnit() {
@@ -307,6 +312,11 @@ unsigned DwarfCompileUnit::getOrCreateSourceID(StringRef FileName, StringRef Dir
Asm->OutStreamer.hasRawTextSupport() ? 0 : getUniqueID());
}
+unsigned DwarfTypeUnit::getOrCreateSourceID(StringRef FileName, StringRef DirName) {
+ return SplitLineTable ? SplitLineTable->getFile(DirName, FileName)
+ : getCU().getOrCreateSourceID(FileName, DirName);
+}
+
/// addOpAddress - Add a dwarf op address data and value using the
/// form given and an op of either DW_FORM_addr or DW_FORM_GNU_addr_index.
///
@@ -394,7 +404,7 @@ void DwarfUnit::addSourceLine(DIE *Die, unsigned Line, StringRef File,
if (Line == 0)
return;
- unsigned FileID = getCU().getOrCreateSourceID(File, Directory);
+ unsigned FileID = getOrCreateSourceID(File, Directory);
assert(FileID && "Invalid file id");
addUInt(Die, dwarf::DW_AT_decl_file, None, FileID);
addUInt(Die, dwarf::DW_AT_decl_line, None, Line);
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
index 705c95bf28a..68954dc5548 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
@@ -23,6 +23,7 @@
#include "llvm/IR/DebugInfo.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCSection.h"
+#include "llvm/MC/MCDwarf.h"
namespace llvm {
@@ -511,6 +512,10 @@ protected:
/// getOrCreateStaticMemberDIE - Create new static data member DIE.
DIE *getOrCreateStaticMemberDIE(DIDerivedType DT);
+ /// Look up the source ID with the given directory and source file names. If
+ /// none currently exists, create a new ID and insert it in the line table.
+ virtual unsigned getOrCreateSourceID(StringRef File, StringRef Directory) = 0;
+
private:
/// constructTypeDIE - Construct basic type die from DIBasicType.
void constructTypeDIE(DIE &Buffer, DIBasicType BTy);
@@ -603,9 +608,7 @@ public:
DwarfCompileUnit &getCU() override { return *this; }
- /// Look up the source ID with the given directory and source file names. If
- /// none currently exists, create a new ID and insert it in the line table.
- unsigned getOrCreateSourceID(StringRef FileName, StringRef DirName);
+ unsigned getOrCreateSourceID(StringRef FileName, StringRef DirName) override;
};
class DwarfTypeUnit : public DwarfUnit {
@@ -613,10 +616,12 @@ private:
uint64_t TypeSignature;
const DIE *Ty;
DwarfCompileUnit &CU;
+ MCDwarfLineTableHeader *SplitLineTable;
public:
DwarfTypeUnit(unsigned UID, DIE *D, DwarfCompileUnit &CU, AsmPrinter *A,
- DwarfDebug *DW, DwarfFile *DWU);
+ DwarfDebug *DW, DwarfFile *DWU,
+ MCDwarfLineTableHeader *SplitLineTable = nullptr);
void setTypeSignature(uint64_t Signature) { TypeSignature = Signature; }
uint64_t getTypeSignature() const { return TypeSignature; }
@@ -631,6 +636,9 @@ public:
}
void initSection(const MCSection *Section);
DwarfCompileUnit &getCU() override { return CU; }
+
+protected:
+ unsigned getOrCreateSourceID(StringRef File, StringRef Directory) override;
};
} // end llvm namespace
#endif
OpenPOWER on IntegriCloud