From 38fbba4cb830e48476781f9135a92450c1f5510d Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Mon, 20 Jul 2020 19:06:20 -0700 Subject: [PATCH] DebugInfo: Move getMD5AsBytes from DwarfUnit to DwarfDebug It wasn't using any state from DwarfUnit anyway. --- llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | 2 +- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 24 ++++++++++++++++++++---- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h | 4 ++++ llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp | 24 +++--------------------- llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h | 4 ---- 5 files changed, 28 insertions(+), 30 deletions(-) diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index 197e0da..d5ce8e5 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -117,7 +117,7 @@ unsigned DwarfCompileUnit::getOrCreateSourceID(const DIFile *File) { return Asm->OutStreamer->emitDwarfFileDirective(0, "", "", None, None, CUID); return Asm->OutStreamer->emitDwarfFileDirective( - 0, File->getDirectory(), File->getFilename(), getMD5AsBytes(File), + 0, File->getDirectory(), File->getFilename(), DD->getMD5AsBytes(File), File->getSource(), CUID); } diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 45ed525..8475081 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -1071,9 +1071,8 @@ DwarfDebug::getOrCreateDwarfCompileUnit(const DICompileUnit *DIUnit) { // compilation directory. if (!Asm->OutStreamer->hasRawTextSupport() || SingleCU) Asm->OutStreamer->emitDwarfFile0Directive( - CompilationDir, DIUnit->getFilename(), - NewCU.getMD5AsBytes(DIUnit->getFile()), DIUnit->getSource(), - NewCU.getUniqueID()); + CompilationDir, DIUnit->getFilename(), getMD5AsBytes(DIUnit->getFile()), + DIUnit->getSource(), NewCU.getUniqueID()); if (useSplitDwarf()) { NewCU.setSkeleton(constructSkeletonCU(NewCU)); @@ -3200,7 +3199,7 @@ MCDwarfDwoLineTable *DwarfDebug::getDwoLineTable(const DwarfCompileUnit &CU) { const DICompileUnit *DIUnit = CU.getCUNode(); SplitTypeUnitFileTable.maybeSetRootFile( DIUnit->getDirectory(), DIUnit->getFilename(), - CU.getMD5AsBytes(DIUnit->getFile()), DIUnit->getSource()); + getMD5AsBytes(DIUnit->getFile()), DIUnit->getSource()); return &SplitTypeUnitFileTable; } @@ -3383,3 +3382,20 @@ void DwarfDebug::insertSectionLabel(const MCSymbol *S) { if (useSplitDwarf() || getDwarfVersion() >= 5) AddrPool.getIndex(S); } + +Optional DwarfDebug::getMD5AsBytes(const DIFile *File) const { + assert(File); + if (getDwarfVersion() < 5) + return None; + Optional> Checksum = File->getChecksum(); + if (!Checksum || Checksum->Kind != DIFile::CSK_MD5) + return None; + + // Convert the string checksum to an MD5Result for the streamer. + // The verifier validates the checksum so we assume it's okay. + // An MD5 checksum is 16 bytes. + std::string ChecksumString = fromHex(Checksum->Value); + MD5::MD5Result CKMem; + std::copy(ChecksumString.begin(), ChecksumString.end(), CKMem.Bytes.data()); + return CKMem; +} diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h index ad2f2f3..2587ee6 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -784,6 +784,10 @@ public: static void emitDebugLocValue(const AsmPrinter &AP, const DIBasicType *BT, const DbgValueLoc &Value, DwarfExpression &DwarfExpr); + + /// If the \p File has an MD5 checksum, return it as an MD5Result + /// allocated in the MCContext. + Optional getMD5AsBytes(const DIFile *File) const; }; } // end namespace llvm diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index bcad8ad..1ba2afe 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -307,23 +307,6 @@ void DwarfUnit::addSectionOffset(DIE &Die, dwarf::Attribute Attribute, addUInt(Die, Attribute, dwarf::DW_FORM_data4, Integer); } -Optional DwarfUnit::getMD5AsBytes(const DIFile *File) const { - assert(File); - if (DD->getDwarfVersion() < 5) - return None; - Optional> Checksum = File->getChecksum(); - if (!Checksum || Checksum->Kind != DIFile::CSK_MD5) - return None; - - // Convert the string checksum to an MD5Result for the streamer. - // The verifier validates the checksum so we assume it's okay. - // An MD5 checksum is 16 bytes. - std::string ChecksumString = fromHex(Checksum->Value); - MD5::MD5Result CKMem; - std::copy(ChecksumString.begin(), ChecksumString.end(), CKMem.Bytes.data()); - return CKMem; -} - unsigned DwarfTypeUnit::getOrCreateSourceID(const DIFile *File) { if (!SplitLineTable) return getCU().getOrCreateSourceID(File); @@ -332,10 +315,9 @@ unsigned DwarfTypeUnit::getOrCreateSourceID(const DIFile *File) { // This is a split type unit that needs a line table. addSectionOffset(getUnitDie(), dwarf::DW_AT_stmt_list, 0); } - return SplitLineTable->getFile(File->getDirectory(), File->getFilename(), - getMD5AsBytes(File), - Asm->OutContext.getDwarfVersion(), - File->getSource()); + return SplitLineTable->getFile( + File->getDirectory(), File->getFilename(), DD->getMD5AsBytes(File), + Asm->OutContext.getDwarfVersion(), File->getSource()); } void DwarfUnit::addOpAddress(DIELoc &Die, const MCSymbol *Sym) { diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h index 34f3a34..8af0cdc 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h @@ -284,10 +284,6 @@ public: const MCSymbol *Label, const MCSymbol *Sec); - /// If the \p File has an MD5 checksum, return it as an MD5Result - /// allocated in the MCContext. - Optional getMD5AsBytes(const DIFile *File) const; - /// Get context owner's DIE. DIE *createTypeDIE(const DICompositeType *Ty); -- 2.7.4