1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 19:42:54 +02:00

[DebugInfo, PDB] Use sparse bitfields for the name map

The name map might not be densely packed on disk.  Using a sparse map
will save memory in such situations.

llvm-svn: 271811
This commit is contained in:
David Majnemer 2016-06-04 22:47:39 +00:00
parent dad6c47e6b
commit 6972cf3620

View File

@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/DebugInfo/PDB/Raw/NameMap.h" #include "llvm/DebugInfo/PDB/Raw/NameMap.h"
#include "llvm/ADT/BitVector.h" #include "llvm/ADT/SparseBitVector.h"
#include "llvm/DebugInfo/CodeView/StreamReader.h" #include "llvm/DebugInfo/CodeView/StreamReader.h"
#include "llvm/DebugInfo/PDB/Raw/RawError.h" #include "llvm/DebugInfo/PDB/Raw/RawError.h"
@ -68,16 +68,16 @@ Error NameMap::load(codeview::StreamReader &Stream) {
return make_error<RawError>(raw_error_code::corrupt_file, return make_error<RawError>(raw_error_code::corrupt_file,
"Number of present words is too large"); "Number of present words is too large");
// Store all the 'present' bits in a vector for later processing. SparseBitVector<> Present;
SmallVector<uint32_t, 1> PresentWords;
for (uint32_t I = 0; I != NumPresentWords; ++I) { for (uint32_t I = 0; I != NumPresentWords; ++I) {
uint32_t Word; uint32_t Word;
if (auto EC = Stream.readInteger(Word)) if (auto EC = Stream.readInteger(Word))
return joinErrors(std::move(EC), return joinErrors(std::move(EC),
make_error<RawError>(raw_error_code::corrupt_file, make_error<RawError>(raw_error_code::corrupt_file,
"Expected name map word")); "Expected name map word"));
for (unsigned Idx = 0; Idx < 32; ++Idx)
PresentWords.push_back(Word); if (Word & (1U << Idx))
Present.set((I * 32) + Idx);
} }
// This appears to be a hash table which uses bitfields to determine whether // This appears to be a hash table which uses bitfields to determine whether
@ -93,30 +93,21 @@ Error NameMap::load(codeview::StreamReader &Stream) {
return make_error<RawError>(raw_error_code::corrupt_file, return make_error<RawError>(raw_error_code::corrupt_file,
"Number of deleted words is too large"); "Number of deleted words is too large");
// Store all the 'deleted' bits in a vector for later processing. SparseBitVector<> Deleted;
SmallVector<uint32_t, 1> DeletedWords;
for (uint32_t I = 0; I != NumDeletedWords; ++I) { for (uint32_t I = 0; I != NumDeletedWords; ++I) {
uint32_t Word; uint32_t Word;
if (auto EC = Stream.readInteger(Word)) if (auto EC = Stream.readInteger(Word))
return joinErrors(std::move(EC), return joinErrors(std::move(EC),
make_error<RawError>(raw_error_code::corrupt_file, make_error<RawError>(raw_error_code::corrupt_file,
"Expected name map deleted word")); "Expected name map word"));
for (unsigned Idx = 0; Idx < 32; ++Idx)
DeletedWords.push_back(Word); if (Word & (1U << Idx))
Deleted.set((I * 32) + Idx);
} }
BitVector Present(MaxNumberOfStrings, false); for (unsigned I : Present) {
if (!PresentWords.empty())
Present.setBitsInMask(PresentWords.data(), PresentWords.size());
BitVector Deleted(MaxNumberOfStrings, false);
if (!DeletedWords.empty())
Deleted.setBitsInMask(DeletedWords.data(), DeletedWords.size());
for (uint32_t I = 0; I < MaxNumberOfStrings; ++I) {
if (!Present.test(I))
continue;
// For all present entries, dump out their mapping. // For all present entries, dump out their mapping.
(void)I;
// This appears to be an offset relative to the start of the strings. // This appears to be an offset relative to the start of the strings.
// It tells us where the null-terminated string begins. // It tells us where the null-terminated string begins.