summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-03-13 17:55:28 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-03-13 17:55:28 +0000
commit11765bce2de81fd3365436524c966d0457556846 (patch)
tree83a83d492b3240179477aa2ce794c89aae850206 /llvm/lib
parent9bc5f36099eb163fbd459fe3b0b8e761e0ec9d32 (diff)
downloadbcm5719-llvm-11765bce2de81fd3365436524c966d0457556846.tar.gz
bcm5719-llvm-11765bce2de81fd3365436524c966d0457556846.zip
MCDwarf: Refactor line table handling into a single data structure
This replaces several "compile unit ID -> thing" mappings in favor of one mapping from CUID to the whole line table structure (files, directories, and lines). This is another step along the way to refactoring out reusable components of line table handling for use when generating debug_line.dwo for fission type units. Also, might be a good basis to fold some of this handling down into MCStreamers to avoid the special case of "One line table when doing asm printing, line table per CU otherwise" by building it into the different MCStreamer implementations. llvm-svn: 203821
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/MC/MCContext.cpp12
-rw-r--r--llvm/lib/MC/MCDwarf.cpp41
-rw-r--r--llvm/lib/MC/MCObjectStreamer.cpp3
3 files changed, 25 insertions, 31 deletions
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index 718c3cefaa3..f7e30f5b067 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -84,13 +84,10 @@ void MCContext::reset() {
Symbols.clear();
Allocator.Reset();
Instances.clear();
- MCDwarfFilesCUMap.clear();
- MCDwarfDirsCUMap.clear();
+ MCDwarfFileTablesCUMap.clear();
MCGenDwarfLabelEntries.clear();
DwarfDebugFlags = StringRef();
- MCLineSections.clear();
DwarfCompileUnitID = 0;
- MCLineTableSymbols.clear();
CurrentDwarfLoc = MCDwarfLoc(0,0,0,DWARF2_FLAG_IS_STMT,0,0);
// If we have the MachO uniquing map, free it.
@@ -337,8 +334,9 @@ unsigned MCContext::GetDwarfFile(StringRef Directory, StringRef FileName,
// Note: in GenericAsmParser::ParseDirectiveFile() FileNumber was checked
// to not be less than one. This needs to be change to be not less than zero.
- SmallVectorImpl<MCDwarfFile *>& MCDwarfFiles = MCDwarfFilesCUMap[CUID];
- SmallVectorImpl<StringRef>& MCDwarfDirs = MCDwarfDirsCUMap[CUID];
+ MCDwarfFileTable &Table = MCDwarfFileTablesCUMap[CUID];
+ SmallVectorImpl<MCDwarfFile *>& MCDwarfFiles = Table.getMCDwarfFiles();
+ SmallVectorImpl<StringRef>& MCDwarfDirs = Table.getMCDwarfDirs();
// Make space for this FileNumber in the MCDwarfFiles vector if needed.
if (FileNumber >= MCDwarfFiles.size()) {
MCDwarfFiles.resize(FileNumber + 1);
@@ -399,7 +397,7 @@ unsigned MCContext::GetDwarfFile(StringRef Directory, StringRef FileName,
/// isValidDwarfFileNumber - takes a dwarf file number and returns true if it
/// currently is assigned and false otherwise.
bool MCContext::isValidDwarfFileNumber(unsigned FileNumber, unsigned CUID) {
- SmallVectorImpl<MCDwarfFile *>& MCDwarfFiles = MCDwarfFilesCUMap[CUID];
+ const SmallVectorImpl<MCDwarfFile *>& MCDwarfFiles = getMCDwarfFiles(CUID);
if(FileNumber == 0 || FileNumber >= MCDwarfFiles.size())
return false;
diff --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp
index 4bc751fd3d7..dc0601d0a61 100644
--- a/llvm/lib/MC/MCDwarf.cpp
+++ b/llvm/lib/MC/MCDwarf.cpp
@@ -82,7 +82,8 @@ void MCLineEntry::Make(MCStreamer *MCOS, const MCSection *Section) {
// Add the line entry to this section's entries.
MCOS->getContext()
- .getMCLineSections()[MCOS->getContext().getDwarfCompileUnitID()]
+ .getMCDwarfFileTable(MCOS->getContext().getDwarfCompileUnitID())
+ .getMCLineSections()
.addLineEntry(LineEntry, Section);
}
@@ -205,27 +206,31 @@ EmitDwarfLineTable(MCStreamer *MCOS, const MCSection *Section,
//
const MCSymbol *MCDwarfFileTable::Emit(MCStreamer *MCOS) {
MCContext &context = MCOS->getContext();
- // Switch to the section where the table will be emitted into.
- MCOS->SwitchSection(context.getObjectFileInfo()->getDwarfLineSection());
- const DenseMap<unsigned, MCSymbol *> &MCLineTableSymbols =
- MCOS->getContext().getMCLineTableSymbols();
// CUID and MCLineTableSymbols are set in DwarfDebug, when DwarfDebug does
// not exist, CUID will be 0 and MCLineTableSymbols will be empty.
// Handle Compile Unit 0, the line table start symbol is the section symbol.
- const MCSymbol *LineStartSym = EmitCU(MCOS, 0);
+ auto I = MCOS->getContext().getMCDwarfFileTables().begin(),
+ E = MCOS->getContext().getMCDwarfFileTables().end();
+
+ // Switch to the section where the table will be emitted into.
+ MCOS->SwitchSection(context.getObjectFileInfo()->getDwarfLineSection());
+
+ const MCSymbol *LineStartSym = I->second.EmitCU(MCOS);
// Handle the rest of the Compile Units.
- for (unsigned Is = 1, Ie = MCLineTableSymbols.size(); Is < Ie; Is++)
- EmitCU(MCOS, Is);
+ for (++I; I != E; ++I)
+ I->second.EmitCU(MCOS);
return LineStartSym;
}
-const MCSymbol *MCDwarfFileTable::EmitCU(MCStreamer *MCOS, unsigned CUID) {
+const MCSymbol *MCDwarfFileTable::EmitCU(MCStreamer *MCOS) const {
MCContext &context = MCOS->getContext();
+
+
// Create a symbol at the beginning of the line table.
- MCSymbol *LineStartSym = MCOS->getContext().getMCLineTableSymbol(CUID);
+ MCSymbol *LineStartSym = Label;
if (!LineStartSym)
LineStartSym = context.CreateTempSymbol();
// Set the value of the symbol, as we are at the start of the line table.
@@ -276,8 +281,6 @@ const MCSymbol *MCDwarfFileTable::EmitCU(MCStreamer *MCOS, unsigned CUID) {
// Put out the directory and file tables.
// First the directory table.
- const SmallVectorImpl<StringRef> &MCDwarfDirs =
- context.getMCDwarfDirs(CUID);
for (unsigned i = 0; i < MCDwarfDirs.size(); i++) {
MCOS->EmitBytes(MCDwarfDirs[i]); // the DirectoryName
MCOS->EmitBytes(StringRef("\0", 1)); // the null term. of the string
@@ -285,8 +288,6 @@ const MCSymbol *MCDwarfFileTable::EmitCU(MCStreamer *MCOS, unsigned CUID) {
MCOS->EmitIntValue(0, 1); // Terminate the directory list
// Second the file table.
- const SmallVectorImpl<MCDwarfFile *> &MCDwarfFiles =
- MCOS->getContext().getMCDwarfFiles(CUID);
for (unsigned i = 1; i < MCDwarfFiles.size(); i++) {
MCOS->EmitBytes(MCDwarfFiles[i]->getName()); // FileName
MCOS->EmitBytes(StringRef("\0", 1)); // the null term. of the string
@@ -302,15 +303,11 @@ const MCSymbol *MCDwarfFileTable::EmitCU(MCStreamer *MCOS, unsigned CUID) {
MCOS->EmitLabel(ProEndSym);
// Put out the line tables.
- const std::map<unsigned, MCLineSection> &MCLineSections =
- MCOS->getContext().getMCLineSections();
- auto Iter = MCLineSections.find(CUID);
- if (Iter != MCLineSections.end())
- for (const auto &LineSec : Iter->second.getMCLineEntries())
- EmitDwarfLineTable(MCOS, LineSec.first, LineSec.second);
+ for (const auto &LineSec : MCLineSections.getMCLineEntries())
+ EmitDwarfLineTable(MCOS, LineSec.first, LineSec.second);
if (MCOS->getContext().getAsmInfo()->getLinkerRequiresNonEmptyDwarfLines() &&
- Iter == MCLineSections.end()) {
+ MCLineSections.getMCLineEntries().empty()) {
// The darwin9 linker has a bug (see PR8715). For for 32-bit architectures
// it requires:
// total_length >= prologue_length + 10
@@ -729,7 +726,7 @@ void MCGenDwarfInfo::Emit(MCStreamer *MCOS, const MCSymbol *LineSectionSymbol) {
MCOS->SwitchSection(context.getObjectFileInfo()->getDwarfARangesSection());
// If there are no line table entries then do not emit any section contents.
- if (context.getMCLineSections().empty())
+ if (!context.hasMCLineSections())
return;
// Output the data for .debug_aranges section.
diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp
index 119df0a083d..996cf5c09b8 100644
--- a/llvm/lib/MC/MCObjectStreamer.cpp
+++ b/llvm/lib/MC/MCObjectStreamer.cpp
@@ -379,8 +379,7 @@ void MCObjectStreamer::EmitZeros(uint64_t NumBytes) {
void MCObjectStreamer::FinishImpl() {
// Dump out the dwarf file & directory tables and line tables.
const MCSymbol *LineSectionSymbol = NULL;
- if (!getContext().getMCLineTableSymbols().empty() ||
- getContext().hasDwarfFiles())
+ if (getContext().hasMCLineSections())
LineSectionSymbol = MCDwarfFileTable::Emit(this);
// If we are generating dwarf for assembly source files dump out the sections.
OpenPOWER on IntegriCloud