summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter
diff options
context:
space:
mode:
authorPaul Robinson <paul.robinson@sony.com>2018-01-09 23:31:48 +0000
committerPaul Robinson <paul.robinson@sony.com>2018-01-09 23:31:48 +0000
commit29f5f987f1b76b5c43310b2062c9f447667a4f80 (patch)
treee19e9304ed5003b04e3a2a2b88c3c833df6a6c1e /llvm/lib/CodeGen/AsmPrinter
parentd72f78e7c8d6dbef66cdbee0292237c68d780160 (diff)
downloadbcm5719-llvm-29f5f987f1b76b5c43310b2062c9f447667a4f80.tar.gz
bcm5719-llvm-29f5f987f1b76b5c43310b2062c9f447667a4f80.zip
[DWARFv5] MC support for MD5 file checksums
Extend .file directive syntax to allow specifying an MD5 checksum for the source file. Emit the checksums in DWARF v5 line tables. llvm-svn: 322134
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp7
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h3
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp5
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp18
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h6
5 files changed, 24 insertions, 15 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index c8cd8eb8ffd..0443bde0cf2 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -95,14 +95,15 @@ void DwarfCompileUnit::addLocalLabelAddress(DIE &Die,
}
unsigned DwarfCompileUnit::getOrCreateSourceID(StringRef FileName,
- StringRef DirName) {
+ StringRef DirName,
+ MD5::MD5Result *Checksum) {
// If we print assembly, we can't separate .file entries according to
// compile units. Thus all files will belong to the default compile unit.
// FIXME: add a better feature test than hasRawTextSupport. Even better,
// extend .file to support this.
return Asm->OutStreamer->EmitDwarfFileDirective(
- 0, DirName, FileName,
+ 0, DirName, FileName, Checksum,
Asm->OutStreamer->hasRawTextSupport() ? 0 : getUniqueID());
}
@@ -443,7 +444,7 @@ DIE *DwarfCompileUnit::constructInlinedScopeDIE(LexicalScope *Scope) {
// Add the call site information to the DIE.
const DILocation *IA = Scope->getInlinedAt();
addUInt(*ScopeDIE, dwarf::DW_AT_call_file, None,
- getOrCreateSourceID(IA->getFilename(), IA->getDirectory()));
+ getOrCreateSourceID(IA->getFilename(), IA->getDirectory(), nullptr));
addUInt(*ScopeDIE, dwarf::DW_AT_call_line, None, IA->getLine());
if (IA->getDiscriminator() && DD->getDwarfVersion() >= 4)
addUInt(*ScopeDIE, dwarf::DW_AT_GNU_discriminator, None,
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
index 68482eb7e35..5cf59c22d9a 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
@@ -141,7 +141,8 @@ public:
DwarfCompileUnit &getCU() override { return *this; }
- unsigned getOrCreateSourceID(StringRef FileName, StringRef DirName) override;
+ unsigned getOrCreateSourceID(StringRef FileName, StringRef DirName,
+ MD5::MD5Result *Checksum) override;
void addImportedEntity(const DIImportedEntity* IE) {
DIScope *Scope = IE->getScope();
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 2c9c7d4f314..a0094b2be2f 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -1378,7 +1378,7 @@ void DwarfDebug::recordSourceLine(unsigned Line, unsigned Col, const MDNode *S,
unsigned CUID = Asm->OutStreamer->getContext().getDwarfCompileUnitID();
Src = static_cast<DwarfCompileUnit &>(*InfoHolder.getUnits()[CUID])
- .getOrCreateSourceID(Fn, Dir);
+ .getOrCreateSourceID(Fn, Dir, nullptr);
}
Asm->OutStreamer->EmitDwarfLocDirective(Src, Line, Col, Flags, 0,
Discriminator, Fn);
@@ -1975,7 +1975,8 @@ void DwarfDebug::emitMacroFile(DIMacroFile &F, DwarfCompileUnit &U) {
Asm->EmitULEB128(F.getLine());
DIFile *File = F.getFile();
unsigned FID =
- U.getOrCreateSourceID(File->getFilename(), File->getDirectory());
+ U.getOrCreateSourceID(File->getFilename(), File->getDirectory(),
+ nullptr); // FIXME: MD5?
Asm->EmitULEB128(FID);
handleMacroNodes(F.getElements(), U);
Asm->EmitULEB128(dwarf::DW_MACINFO_end_file);
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
index 576b9a91ddc..28e63c2ae2c 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -263,9 +263,12 @@ void DwarfUnit::addSectionOffset(DIE &Die, dwarf::Attribute Attribute,
addUInt(Die, Attribute, dwarf::DW_FORM_data4, Integer);
}
-unsigned DwarfTypeUnit::getOrCreateSourceID(StringRef FileName, StringRef DirName) {
- return SplitLineTable ? SplitLineTable->getFile(DirName, FileName)
- : getCU().getOrCreateSourceID(FileName, DirName);
+unsigned DwarfTypeUnit::getOrCreateSourceID(StringRef FileName,
+ StringRef DirName,
+ MD5::MD5Result *Checksum) {
+ return SplitLineTable
+ ? SplitLineTable->getFile(DirName, FileName, Checksum)
+ : getCU().getOrCreateSourceID(FileName, DirName, Checksum);
}
void DwarfUnit::addOpAddress(DIELoc &Die, const MCSymbol *Sym) {
@@ -340,7 +343,7 @@ void DwarfUnit::addSourceLine(DIE &Die, unsigned Line, StringRef File,
if (Line == 0)
return;
- unsigned FileID = getOrCreateSourceID(File, Directory);
+ unsigned FileID = getOrCreateSourceID(File, Directory, nullptr);
assert(FileID && "Invalid file id");
addUInt(Die, dwarf::DW_AT_decl_file, None, FileID);
addUInt(Die, dwarf::DW_AT_decl_line, None, Line);
@@ -1161,9 +1164,10 @@ bool DwarfUnit::applySubprogramDefinitionAttributes(const DISubprogram *SP,
// Look at the Decl's linkage name only if we emitted it.
if (DD->useAllLinkageNames())
DeclLinkageName = SPDecl->getLinkageName();
- unsigned DeclID =
- getOrCreateSourceID(SPDecl->getFilename(), SPDecl->getDirectory());
- unsigned DefID = getOrCreateSourceID(SP->getFilename(), SP->getDirectory());
+ unsigned DeclID = getOrCreateSourceID(SPDecl->getFilename(),
+ SPDecl->getDirectory(), nullptr);
+ unsigned DefID =
+ getOrCreateSourceID(SP->getFilename(), SP->getDirectory(), nullptr);
if (DeclID != DefID)
addUInt(SPDie, dwarf::DW_AT_decl_file, None, DefID);
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
index 4cc01b3298d..43b23f415c4 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
@@ -308,7 +308,8 @@ protected:
/// 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;
+ virtual unsigned getOrCreateSourceID(StringRef File, StringRef Directory,
+ MD5::MD5Result *Checksum) = 0;
/// Look in the DwarfDebug map for the MDNode that corresponds to the
/// reference.
@@ -358,7 +359,8 @@ class DwarfTypeUnit final : public DwarfUnit {
DwarfCompileUnit &CU;
MCDwarfDwoLineTable *SplitLineTable;
- unsigned getOrCreateSourceID(StringRef File, StringRef Directory) override;
+ unsigned getOrCreateSourceID(StringRef File, StringRef Directory,
+ MD5::MD5Result *Checksum) override;
bool isDwoUnit() const override;
public:
OpenPOWER on IntegriCloud