Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit c6b77e5

Browse files
committed
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271811 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 4239e23 commit c6b77e5

File tree

1 file changed

+12
-21
lines changed

1 file changed

+12
-21
lines changed

lib/DebugInfo/PDB/Raw/NameMap.cpp

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
//===----------------------------------------------------------------------===//
99

1010
#include "llvm/DebugInfo/PDB/Raw/NameMap.h"
11-
#include "llvm/ADT/BitVector.h"
11+
#include "llvm/ADT/SparseBitVector.h"
1212
#include "llvm/DebugInfo/CodeView/StreamReader.h"
1313
#include "llvm/DebugInfo/PDB/Raw/RawError.h"
1414

@@ -68,16 +68,16 @@ Error NameMap::load(codeview::StreamReader &Stream) {
6868
return make_error<RawError>(raw_error_code::corrupt_file,
6969
"Number of present words is too large");
7070

71-
// Store all the 'present' bits in a vector for later processing.
72-
SmallVector<uint32_t, 1> PresentWords;
71+
SparseBitVector<> Present;
7372
for (uint32_t I = 0; I != NumPresentWords; ++I) {
7473
uint32_t Word;
7574
if (auto EC = Stream.readInteger(Word))
7675
return joinErrors(std::move(EC),
7776
make_error<RawError>(raw_error_code::corrupt_file,
7877
"Expected name map word"));
79-
80-
PresentWords.push_back(Word);
78+
for (unsigned Idx = 0; Idx < 32; ++Idx)
79+
if (Word & (1U << Idx))
80+
Present.set((I * 32) + Idx);
8181
}
8282

8383
// This appears to be a hash table which uses bitfields to determine whether
@@ -93,30 +93,21 @@ Error NameMap::load(codeview::StreamReader &Stream) {
9393
return make_error<RawError>(raw_error_code::corrupt_file,
9494
"Number of deleted words is too large");
9595

96-
// Store all the 'deleted' bits in a vector for later processing.
97-
SmallVector<uint32_t, 1> DeletedWords;
96+
SparseBitVector<> Deleted;
9897
for (uint32_t I = 0; I != NumDeletedWords; ++I) {
9998
uint32_t Word;
10099
if (auto EC = Stream.readInteger(Word))
101100
return joinErrors(std::move(EC),
102101
make_error<RawError>(raw_error_code::corrupt_file,
103-
"Expected name map deleted word"));
104-
105-
DeletedWords.push_back(Word);
102+
"Expected name map word"));
103+
for (unsigned Idx = 0; Idx < 32; ++Idx)
104+
if (Word & (1U << Idx))
105+
Deleted.set((I * 32) + Idx);
106106
}
107107

108-
BitVector Present(MaxNumberOfStrings, false);
109-
if (!PresentWords.empty())
110-
Present.setBitsInMask(PresentWords.data(), PresentWords.size());
111-
BitVector Deleted(MaxNumberOfStrings, false);
112-
if (!DeletedWords.empty())
113-
Deleted.setBitsInMask(DeletedWords.data(), DeletedWords.size());
114-
115-
for (uint32_t I = 0; I < MaxNumberOfStrings; ++I) {
116-
if (!Present.test(I))
117-
continue;
118-
108+
for (unsigned I : Present) {
119109
// For all present entries, dump out their mapping.
110+
(void)I;
120111

121112
// This appears to be an offset relative to the start of the strings.
122113
// It tells us where the null-terminated string begins.

0 commit comments

Comments
 (0)