diff options
author | David Blaikie <dblaikie@gmail.com> | 2014-01-03 04:20:26 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2014-01-03 04:20:26 +0000 |
commit | ddb66281cd881b674f86c2798b9c99cac0adc202 (patch) | |
tree | 2b506cc0202153ff07c786dc7484f3131de1294b /llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | |
parent | 76bc5157c2406ba919069f7bf341ded0a6ecdda8 (diff) | |
download | bcm5719-llvm-ddb66281cd881b674f86c2798b9c99cac0adc202.tar.gz bcm5719-llvm-ddb66281cd881b674f86c2798b9c99cac0adc202.zip |
Debug Info: Type Units: Simplify type hashing using IR-provided unique names.
What's good for LTO metadata size problems ought to be good for non-LTO
debug info size too, so let's rely on the same uniqueness in both cases.
If it's insufficient for non-LTO for whatever reason (since we now won't
be uniquing CU-local types or any C types - but these are likely to not
be the most significant contributors to type bloat) we should consider a
frontend solution that'll help both LTO and non-LTO alike, rather than
using DWARF-level DIE-hashing that only helps non-LTO debug info size.
It's also much simpler this way and benefits C++ even more since we can
deduplicate lexically separate definitions of the same C++ type since
they have the same mangled name.
llvm-svn: 198397
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 62 |
1 files changed, 10 insertions, 52 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index a0052f605d7..e8e1e50c9b9 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -58,11 +58,6 @@ static cl::opt<bool> UnknownLocations( cl::desc("Make an absence of debug location information explicit."), cl::init(false)); -static cl::opt<bool> -GenerateODRHash("generate-odr-hash", cl::Hidden, - cl::desc("Add an ODR hash to external type DIEs."), - cl::init(false)); - static cl::opt<bool> GenerateCUHash("generate-cu-hash", cl::Hidden, cl::desc("Add the CU hash as the dwo_id."), cl::init(false)); @@ -1019,41 +1014,6 @@ void DwarfDebug::collectDeadVariables() { } } -// Type Signature [7.27] and ODR Hash code. - -/// \brief Grabs the string in whichever attribute is passed in and returns -/// a reference to it. Returns "" if the attribute doesn't exist. -static StringRef getDIEStringAttr(DIE *Die, unsigned Attr) { - DIEValue *V = Die->findAttribute(Attr); - - if (DIEString *S = dyn_cast_or_null<DIEString>(V)) - return S->getString(); - - return StringRef(""); -} - -/// Return true if the current DIE is contained within an anonymous namespace. -static bool isContainedInAnonNamespace(DIE *Die) { - DIE *Parent = Die->getParent(); - - while (Parent) { - if (Parent->getTag() == dwarf::DW_TAG_namespace && - getDIEStringAttr(Parent, dwarf::DW_AT_name) == "") - return true; - Parent = Parent->getParent(); - } - - return false; -} - -/// Test if the current CU language is C++ and that we have -/// a named type that is not contained in an anonymous namespace. -static bool shouldAddODRHash(DwarfTypeUnit *CU, DIE *Die) { - return CU->getLanguage() == dwarf::DW_LANG_C_plus_plus && - getDIEStringAttr(Die, dwarf::DW_AT_name) != "" && - !isContainedInAnonNamespace(Die); -} - void DwarfDebug::finalizeModuleInfo() { // Collect info for variables that were optimized out. collectDeadVariables(); @@ -3041,8 +3001,8 @@ void DwarfDebug::emitDebugStrDWO() { OffSec, StrSym); } -void DwarfDebug::addDwarfTypeUnitType(uint16_t Language, DIE *RefDie, - DICompositeType CTy) { +void DwarfDebug::addDwarfTypeUnitType(uint16_t Language, StringRef Identifier, + DIE *RefDie, DICompositeType CTy) { const DwarfTypeUnit *&TU = DwarfTypeUnits[CTy]; if (!TU) { DIE *UnitDie = new DIE(dwarf::DW_TAG_type_unit); @@ -3057,16 +3017,14 @@ void DwarfDebug::addDwarfTypeUnitType(uint16_t Language, DIE *RefDie, DIE *Die = NewTU->createTypeDIE(CTy); - if (GenerateODRHash && shouldAddODRHash(NewTU, Die)) - NewTU->addUInt(UnitDie, dwarf::DW_AT_GNU_odr_signature, - dwarf::DW_FORM_data8, - DIEHash().computeDIEODRSignature(*Die)); - // FIXME: This won't handle circularly referential structures, as the DIE - // may have references to other DIEs still under construction and missing - // their signature. Hashing should walk through the signatures to their - // referenced type, or possibly walk the precomputed hashes of related types - // at the end. - uint64_t Signature = DIEHash().computeTypeSignature(*Die); + MD5 Hash; + Hash.update(Identifier); + // ... take the least significant 8 bytes and return those. Our MD5 + // implementation always returns its results in little endian, swap bytes + // appropriately. + MD5::MD5Result Result; + Hash.final(Result); + uint64_t Signature = *reinterpret_cast<uint64_t *>(Result + 8); NewTU->setTypeSignature(Signature); NewTU->setType(Die); |