diff options
author | Eric Christopher <echristo@gmail.com> | 2014-03-08 00:29:41 +0000 |
---|---|---|
committer | Eric Christopher <echristo@gmail.com> | 2014-03-08 00:29:41 +0000 |
commit | 4f17ee09f9597cde402322e971d682786364b1bf (patch) | |
tree | 1061dd206eccd3c213cfcea1b9c5f4f743669fde /llvm/lib/CodeGen | |
parent | 664b32b814a38903ad4becd439dda1530e7f0827 (diff) | |
download | bcm5719-llvm-4f17ee09f9597cde402322e971d682786364b1bf.tar.gz bcm5719-llvm-4f17ee09f9597cde402322e971d682786364b1bf.zip |
Add support for hashing location information for CU level hashes.
Add a testcase based on sret.cpp where we can now hash the entire
compile unit.
llvm-svn: 203319
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DIEHash.cpp | 34 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DIEHash.h | 3 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h | 12 |
3 files changed, 43 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DIEHash.cpp b/llvm/lib/CodeGen/AsmPrinter/DIEHash.cpp index cff8f2180a9..024ce0e7250 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DIEHash.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DIEHash.cpp @@ -13,8 +13,10 @@ #define DEBUG_TYPE "dwarfdebug" +#include "ByteStreamer.h" #include "DIEHash.h" #include "DIE.h" +#include "DwarfDebug.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" #include "llvm/CodeGen/AsmPrinter.h" @@ -279,6 +281,28 @@ void DIEHash::hashBlockData(const SmallVectorImpl<DIEValue *> &Values) { Hash.update((uint64_t)cast<DIEInteger>(*I)->getValue()); } +// Hash the contents of a loclistptr class. +void DIEHash::hashLocList(const DIELocList &LocList) { + SmallVectorImpl<DotDebugLocEntry>::const_iterator Start = + AP->getDwarfDebug()->getDebugLocEntries().begin(); + Start += LocList.getValue(); + HashingByteStreamer Streamer(*this); + for (SmallVectorImpl<DotDebugLocEntry>::const_iterator + I = Start, + E = AP->getDwarfDebug()->getDebugLocEntries().end(); + I != E; ++I) { + const DotDebugLocEntry &Entry = *I; + // Go through the entries until we hit the end of the list, + // which is the next empty entry. + if (Entry.isEmpty()) + return; + else if (Entry.isMerged()) + continue; + else + AP->getDwarfDebug()->emitDebugLocEntry(Streamer, Entry); + } +} + // Hash an individual attribute \param Attr based on the type of attribute and // the form. void DIEHash::hashAttribute(AttrEntry Attr, dwarf::Tag Tag) { @@ -333,19 +357,23 @@ void DIEHash::hashAttribute(AttrEntry Attr, dwarf::Tag Tag) { break; case DIEValue::isBlock: case DIEValue::isLoc: + case DIEValue::isLocList: addULEB128('A'); addULEB128(Attribute); addULEB128(dwarf::DW_FORM_block); if (isa<DIEBlock>(Value)) { addULEB128(cast<DIEBlock>(Value)->ComputeSize(AP)); hashBlockData(cast<DIEBlock>(Value)->getValues()); - } else { + } else if (isa<DIELoc>(Value)) { addULEB128(cast<DIELoc>(Value)->ComputeSize(AP)); hashBlockData(cast<DIELoc>(Value)->getValues()); + } else { + // We could add the block length, but that would take + // a bit of work and not add a lot of uniqueness + // to the hash in some way we could test. + hashLocList(*cast<DIELocList>(Value)); } break; - // FIXME: Handle loclistptr. - case DIEValue::isLocList: // FIXME: It's uncertain whether or not we should handle this at the moment. case DIEValue::isExpr: case DIEValue::isLabel: diff --git a/llvm/lib/CodeGen/AsmPrinter/DIEHash.h b/llvm/lib/CodeGen/AsmPrinter/DIEHash.h index c3db2d06ca4..48f16011e8b 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DIEHash.h +++ b/llvm/lib/CodeGen/AsmPrinter/DIEHash.h @@ -137,6 +137,9 @@ private: /// DW_FORM_exprloc. void hashBlockData(const SmallVectorImpl<DIEValue *> &Values); + /// \brief Hashes the contents pointed to in the .debug_loc section. + void hashLocList(const DIELocList &LocList); + /// \brief Hashes an individual attribute. void hashAttribute(AttrEntry Attr, dwarf::Tag Tag); diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h index 0dadb73562e..b8cfdd354b1 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -588,9 +588,6 @@ class DwarfDebug : public AsmPrinterHandler { /// \brief Emit visible names into a debug str section. void emitDebugStr(); - /// \brief Emit an entry for the debug loc section. - void emitDebugLocEntry(ByteStreamer &Streamer, const DotDebugLocEntry &Entry); - /// \brief Emit visible names into a debug loc section. void emitDebugLoc(); @@ -761,6 +758,15 @@ public: /// Returns the section symbol for the .debug_loc section. MCSymbol *getDebugLocSym() const { return DwarfDebugLocSectionSym; } + /// Returns the entries for the .debug_loc section. + const SmallVectorImpl<DotDebugLocEntry> &getDebugLocEntries() const { + return DotDebugLocEntries; + } + + /// \brief Emit an entry for the debug loc section. This can be used to + /// handle an entry that's going to be emitted into the debug loc section. + void emitDebugLocEntry(ByteStreamer &Streamer, const DotDebugLocEntry &Entry); + /// Find the MDNode for the given reference. template <typename T> T resolve(DIRef<T> Ref) const { return Ref.resolve(TypeIdentifierMap); |