summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter
diff options
context:
space:
mode:
authorPaul Robinson <paul.robinson@sony.com>2018-03-29 17:16:41 +0000
committerPaul Robinson <paul.robinson@sony.com>2018-03-29 17:16:41 +0000
commitb271f31d8d31ad689958fb8ff75110c2db5515df (patch)
tree9fc7456a6408dc5f91f66d7975f02bfc378de9d6 /llvm/lib/CodeGen/AsmPrinter
parent1b20416bfa4ed906d5b5f289aa8a4430b9620132 (diff)
downloadbcm5719-llvm-b271f31d8d31ad689958fb8ff75110c2db5515df.tar.gz
bcm5719-llvm-b271f31d8d31ad689958fb8ff75110c2db5515df.zip
Reapply "[DWARFv5] Emit file 0 to the line table."
DWARF v5 specifies that the root file (also given in the DW_AT_name attribute of the compilation unit DIE) should be emitted explicitly to the line table's list of files. This makes the line table more independent of the .debug_info section. We emit the new syntax only for DWARF v5 and later. Fixes the bug found by asan. Also XFAIL the new test for Darwin, which is stuck on DWARF v2, and fix up other tests so they stop failing on Windows. Last but not least, don't break "clang -g" of an assembler file that has .file directives in it. Differential Revision: https://reviews.llvm.org/D44054 llvm-svn: 328805
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp11
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp4
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h8
3 files changed, 14 insertions, 9 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 024472db87c..0398d0f4c97 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -499,8 +499,9 @@ DwarfDebug::getOrCreateDwarfCompileUnit(const DICompileUnit *DIUnit) {
// explicitly describe the directory of all files, never relying on the
// compilation directory.
if (!Asm->OutStreamer->hasRawTextSupport() || SingleCU)
- Asm->OutStreamer->getContext().setMCLineTableCompilationDir(
- NewCU.getUniqueID(), CompilationDir);
+ Asm->OutStreamer->emitDwarfFile0Directive(
+ CompilationDir, FN, NewCU.getMD5AsBytes(DIUnit->getFile()),
+ DIUnit->getSource(), NewCU.getUniqueID());
StringRef Producer = DIUnit->getProducer();
StringRef Flags = DIUnit->getFlags();
@@ -2148,8 +2149,10 @@ void DwarfDebug::emitDebugStrDWO() {
MCDwarfDwoLineTable *DwarfDebug::getDwoLineTable(const DwarfCompileUnit &CU) {
if (!useSplitDwarf())
return nullptr;
- if (SingleCU)
- SplitTypeUnitFileTable.setCompilationDir(CU.getCUNode()->getDirectory());
+ const DICompileUnit *DIUnit = CU.getCUNode();
+ SplitTypeUnitFileTable.maybeSetRootFile(
+ DIUnit->getDirectory(), DIUnit->getFilename(),
+ CU.getMD5AsBytes(DIUnit->getFile()), DIUnit->getSource());
return &SplitTypeUnitFileTable;
}
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
index 811112a0430..4bbfb4704e6 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -282,8 +282,10 @@ void DwarfUnit::addSectionOffset(DIE &Die, dwarf::Attribute Attribute,
addUInt(Die, Attribute, dwarf::DW_FORM_data4, Integer);
}
-MD5::MD5Result *DwarfUnit::getMD5AsBytes(const DIFile *File) {
+MD5::MD5Result *DwarfUnit::getMD5AsBytes(const DIFile *File) const {
assert(File);
+ if (DD->getDwarfVersion() < 5)
+ return nullptr;
Optional<DIFile::ChecksumInfo<StringRef>> Checksum = File->getChecksum();
if (!Checksum || Checksum->Kind != DIFile::CSK_MD5)
return nullptr;
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
index 328e3549e05..c1d46173567 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
@@ -306,6 +306,10 @@ public:
const MCSymbol *Label,
const MCSymbol *Sec);
+ /// If the \p File has an MD5 checksum, return it as an MD5Result
+ /// allocated in the MCContext.
+ MD5::MD5Result *getMD5AsBytes(const DIFile *File) const;
+
protected:
~DwarfUnit();
@@ -316,10 +320,6 @@ protected:
/// create a new ID and insert it in the line table.
virtual unsigned getOrCreateSourceID(const DIFile *File) = 0;
- /// If the \p File has an MD5 checksum, return it as an MD5Result
- /// allocated in the MCContext.
- MD5::MD5Result *getMD5AsBytes(const DIFile *File);
-
/// Look in the DwarfDebug map for the MDNode that corresponds to the
/// reference.
template <typename T> T *resolve(TypedDINodeRef<T> Ref) const {
OpenPOWER on IntegriCloud