[llvm] r319260 - [NFC] Minor cleanups in CodeView TypeTableBuilder.

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 28 15:57:13 PST 2017


Author: zturner
Date: Tue Nov 28 15:57:13 2017
New Revision: 319260

URL: http://llvm.org/viewvc/llvm-project?rev=319260&view=rev
Log:
[NFC] Minor cleanups in CodeView TypeTableBuilder.

Modified:
    llvm/trunk/include/llvm/DebugInfo/CodeView/TypeTableBuilder.h
    llvm/trunk/lib/DebugInfo/CodeView/TypeTableBuilder.cpp

Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/TypeTableBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/TypeTableBuilder.h?rev=319260&r1=319259&r2=319260&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/TypeTableBuilder.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/TypeTableBuilder.h Tue Nov 28 15:57:13 2017
@@ -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 TypeVisi
 
 public:
   explicit TypeTableBuilder(BumpPtrAllocator &Storage, bool Hash = true);
-  ~TypeTableBuilder() override;
+  ~TypeTableBuilder();
 
   void reset();
 

Modified: llvm/trunk/lib/DebugInfo/CodeView/TypeTableBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/TypeTableBuilder.cpp?rev=319260&r1=319259&r2=319260&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/TypeTableBuilder.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/TypeTableBuilder.cpp Tue Nov 28 15:57:13 2017
@@ -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<uint8_t> Data;
   TypeIndex Index;
 };
 
@@ -67,9 +66,9 @@ template <> struct DenseMapInfo<HashedTy
     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(
   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(
 
     uint8_t *Stable = RecordStorage.Allocate<uint8_t>(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<uint8_t>(Hashed->Data, Hashed->Size);
+  Record = Hashed->Data;
   return Hashed->Index;
 }
 




More information about the llvm-commits mailing list