From: Zachary Turner Date: Tue, 28 Nov 2017 23:57:13 +0000 (+0000) Subject: [NFC] Minor cleanups in CodeView TypeTableBuilder. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dc4f5ff552f66fb72a5d7916f88afb8834f813dc;p=llvm [NFC] Minor cleanups in CodeView TypeTableBuilder. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319260 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/DebugInfo/CodeView/TypeTableBuilder.h b/include/llvm/DebugInfo/CodeView/TypeTableBuilder.h index ff90f8ca6de..6b5cb3a9b5f 100644 --- a/include/llvm/DebugInfo/CodeView/TypeTableBuilder.h +++ b/include/llvm/DebugInfo/CodeView/TypeTableBuilder.h @@ -35,7 +35,7 @@ namespace codeview { class ContinuationRecordBuilder; class TypeHasher; -class TypeTableBuilder : public TypeVisitorCallbacks { +class TypeTableBuilder { BumpPtrAllocator &RecordStorage; SimpleTypeSerializer SimpleSerializer; @@ -52,7 +52,7 @@ class TypeTableBuilder : public TypeVisitorCallbacks { public: explicit TypeTableBuilder(BumpPtrAllocator &Storage, bool Hash = true); - ~TypeTableBuilder() override; + ~TypeTableBuilder(); void reset(); diff --git a/lib/DebugInfo/CodeView/TypeTableBuilder.cpp b/lib/DebugInfo/CodeView/TypeTableBuilder.cpp index bce636f3894..7b02b175bd6 100644 --- a/lib/DebugInfo/CodeView/TypeTableBuilder.cpp +++ b/lib/DebugInfo/CodeView/TypeTableBuilder.cpp @@ -31,9 +31,8 @@ using namespace llvm::codeview; namespace { struct HashedType { - uint64_t Hash; - const uint8_t *Data; - unsigned Size; // FIXME: Go to uint16_t? + unsigned Hash; + ArrayRef Data; TypeIndex Index; }; @@ -67,9 +66,9 @@ template <> struct DenseMapInfo { HashedType *RHS = RHSP.Ptr; if (RHS == getEmptyKey().Ptr || RHS == getTombstoneKey().Ptr) return LHS == RHS; - if (LHS->Hash != RHS->Hash || LHS->Size != RHS->Size) + if (LHS->Hash != RHS->Hash) return false; - return ::memcmp(LHS->Data, RHS->Data, LHS->Size) == 0; + return LHS->Data == RHS->Data; } }; @@ -111,8 +110,7 @@ TypeIndex TypeHasher::getOrCreateRecord(ArrayRef &Record, assert(Record.size() % 4 == 0 && "Record is not aligned to 4 bytes!"); // Compute the hash up front so we can store it in the key. - HashedType TempHashedType = {hash_value(Record), Record.data(), - unsigned(Record.size()), TI}; + HashedType TempHashedType = {hash_value(Record), Record, TI}; auto Result = HashedRecords.insert(HashedTypePtr(&TempHashedType)); HashedType *&Hashed = Result.first->Ptr; @@ -124,12 +122,11 @@ TypeIndex TypeHasher::getOrCreateRecord(ArrayRef &Record, uint8_t *Stable = RecordStorage.Allocate(Record.size()); memcpy(Stable, Record.data(), Record.size()); - Hashed->Data = Stable; - assert(Hashed->Size == Record.size()); + Hashed->Data = makeArrayRef(Stable, Record.size()); } // Update the caller's copy of Record to point a stable copy. - Record = ArrayRef(Hashed->Data, Hashed->Size); + Record = Hashed->Data; return Hashed->Index; }