Index: llvm/trunk/include/llvm/DebugInfo/PDB/Native/TpiStream.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/PDB/Native/TpiStream.h +++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/TpiStream.h @@ -40,12 +40,12 @@ uint32_t TypeIndexBegin() const; uint32_t TypeIndexEnd() const; - uint32_t NumTypeRecords() const; + uint32_t getNumTypeRecords() const; uint16_t getTypeHashStreamIndex() const; uint16_t getTypeHashStreamAuxIndex() const; uint32_t getHashKeySize() const; - uint32_t NumHashBuckets() const; + uint32_t getNumHashBuckets() const; FixedStreamArray getHashValues() const; FixedStreamArray getTypeIndexOffsets() const; HashTable &getHashAdjusters(); @@ -55,8 +55,6 @@ Error commit(); private: - Error verifyHashValues(); - const PDBFile &Pdb; std::unique_ptr Stream; Index: llvm/trunk/lib/DebugInfo/PDB/Native/TpiStream.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/PDB/Native/TpiStream.cpp +++ llvm/trunk/lib/DebugInfo/PDB/Native/TpiStream.cpp @@ -39,20 +39,6 @@ TpiStream::~TpiStream() = default; -// Verifies that a given type record matches with a given hash value. -// Currently we only verify SRC_LINE records. -Error TpiStream::verifyHashValues() { - TpiHashVerifier Verifier(HashValues, Header->NumHashBuckets); - TypeDeserializer Deserializer; - - TypeVisitorCallbackPipeline Pipeline; - Pipeline.addCallbackToPipeline(Deserializer); - Pipeline.addCallbackToPipeline(Verifier); - - CVTypeVisitor Visitor(Pipeline); - return Visitor.visitTypeStream(TypeRecords); -} - Error TpiStream::reload() { BinaryStreamReader Reader(*Stream); @@ -98,7 +84,7 @@ // There should be a hash value for every type record, or no hashes at all. uint32_t NumHashValues = Header->HashValueBuffer.Length / sizeof(ulittle32_t); - if (NumHashValues != NumTypeRecords() && NumHashValues != 0) + if (NumHashValues != getNumTypeRecords() && NumHashValues != 0) return make_error( raw_error_code::corrupt_file, "TPI hash count does not match with the number of type records."); @@ -122,12 +108,6 @@ } HashStream = std::move(HS); - - // TPI hash table is a parallel array for the type records. - // Verify that the hash values match with type records. - if (NumHashValues > 0) - if (auto EC = verifyHashValues()) - return EC; } return Error::success(); @@ -142,7 +122,7 @@ uint32_t TpiStream::TypeIndexEnd() const { return Header->TypeIndexEnd; } -uint32_t TpiStream::NumTypeRecords() const { +uint32_t TpiStream::getNumTypeRecords() const { return TypeIndexEnd() - TypeIndexBegin(); } @@ -154,7 +134,7 @@ return Header->HashAuxStreamIndex; } -uint32_t TpiStream::NumHashBuckets() const { return Header->NumHashBuckets; } +uint32_t TpiStream::getNumHashBuckets() const { return Header->NumHashBuckets; } uint32_t TpiStream::getHashKeySize() const { return Header->HashKeySize; } FixedStreamArray TpiStream::getHashValues() const { Index: llvm/trunk/tools/llvm-pdbdump/LLVMOutputStyle.cpp =================================================================== --- llvm/trunk/tools/llvm-pdbdump/LLVMOutputStyle.cpp +++ llvm/trunk/tools/llvm-pdbdump/LLVMOutputStyle.cpp @@ -39,6 +39,7 @@ #include "llvm/DebugInfo/PDB/Native/PDBFile.h" #include "llvm/DebugInfo/PDB/Native/PublicsStream.h" #include "llvm/DebugInfo/PDB/Native/RawError.h" +#include "llvm/DebugInfo/PDB/Native/TpiHashing.h" #include "llvm/DebugInfo/PDB/Native/TpiStream.h" #include "llvm/DebugInfo/PDB/PDBExtras.h" #include "llvm/Object/COFF.h" @@ -622,7 +623,7 @@ StreamScope = llvm::make_unique(P, Label); P.printNumber(VerLabel, Tpi->getTpiVersion()); - P.printNumber("Record count", Tpi->NumTypeRecords()); + P.printNumber("Record count", Tpi->getNumTypeRecords()); Optional &StreamDB = (StreamIdx == StreamTPI) ? TypeDB : ItemDB; @@ -682,7 +683,7 @@ if (DumpTpiHash) { DictScope DD(P, "Hash"); - P.printNumber("Number of Hash Buckets", Tpi->NumHashBuckets()); + P.printNumber("Number of Hash Buckets", Tpi->getNumHashBuckets()); P.printNumber("Hash Key Size", Tpi->getHashKeySize()); P.printList("Values", Tpi->getHashValues()); @@ -723,16 +724,25 @@ DB.emplace(); + auto Tpi = + (SN == StreamTPI) ? File.getPDBTpiStream() : File.getPDBIpiStream(); + + if (!Tpi) + return Tpi.takeError(); + TypeVisitorCallbackPipeline Pipeline; TypeDeserializer Deserializer; TypeDatabaseVisitor DBV(*DB); Pipeline.addCallbackToPipeline(Deserializer); Pipeline.addCallbackToPipeline(DBV); - auto Tpi = - (SN == StreamTPI) ? File.getPDBTpiStream() : File.getPDBIpiStream(); - if (!Tpi) - return Tpi.takeError(); + auto HashValues = Tpi->getHashValues(); + std::unique_ptr HashVerifier; + if (!HashValues.empty()) { + HashVerifier = + make_unique(HashValues, Tpi->getNumHashBuckets()); + Pipeline.addCallbackToPipeline(*HashVerifier); + } CVTypeVisitor Visitor(Pipeline); return Visitor.visitTypeStream(Tpi->types(nullptr));