summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/PDB/Native
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2019-07-15 18:56:56 +0000
committerNico Weber <nicolasweber@gmx.de>2019-07-15 18:56:56 +0000
commitac6375d99d19e2c8c53dc72caa457833f6fa6641 (patch)
treef9b5015534f1fe7e17cba1ca56ef407d399d5800 /llvm/lib/DebugInfo/PDB/Native
parentdc56995c57451368b4049738d4a56fa042db7a6e (diff)
downloadbcm5719-llvm-ac6375d99d19e2c8c53dc72caa457833f6fa6641.tar.gz
bcm5719-llvm-ac6375d99d19e2c8c53dc72caa457833f6fa6641.zip
Expand comment about how StringsToBuckets was computed, and add more entries
The construction was explained in https://reviews.llvm.org/D44810?id=139526#inline-391999 but reading the code shouldn't require hunting down old reviews to understand it. The precomputed list was missing an entry for the empty list case, and one entry at the very end. (The current last entry is the last one where 3 * BucketCount fits in a signed int, but the reference implementation uses unsigneds as far as I can tell, so there's room for one more entry.) No behavior change for inputs seen in practice. Differential Revision: https://reviews.llvm.org/D64738 llvm-svn: 366107
Diffstat (limited to 'llvm/lib/DebugInfo/PDB/Native')
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/PDBStringTableBuilder.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Native/PDBStringTableBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/PDBStringTableBuilder.cpp
index eabb9d44669..f7f36901e4d 100644
--- a/llvm/lib/DebugInfo/PDB/Native/PDBStringTableBuilder.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/PDBStringTableBuilder.cpp
@@ -60,7 +60,19 @@ static uint32_t computeBucketCount(uint32_t NumStrings) {
// strings. Matching the reference algorithm exactly is not strictly
// necessary for correctness, but it helps when comparing LLD's PDBs with
// Microsoft's PDBs so as to eliminate superfluous differences.
+ // The reference implementation does (in nmt.h, NMT::grow()):
+ // unsigned StringCount = 0;
+ // unsigned BucketCount = 1;
+ // fn insert() {
+ // ++StringCount;
+ // if (BucketCount * 3 / 4 < StringCount)
+ // BucketCount = BucketCount * 3 / 2 + 1;
+ // }
+ // This list contains all StringCount, BucketCount pairs where BucketCount was
+ // just incremented. It ends before the first BucketCount entry where
+ // BucketCount * 3 would overflow a 32-bit unsigned int.
static std::map<uint32_t, uint32_t> StringsToBuckets = {
+ {0, 1},
{1, 2},
{2, 4},
{4, 7},
@@ -110,7 +122,8 @@ static uint32_t computeBucketCount(uint32_t NumStrings) {
{229865455, 459730910},
{344798183, 689596366},
{517197275, 1034394550},
- {775795913, 1551591826}};
+ {775795913, 1551591826},
+ {1163693870, 2327387740}};
auto Entry = StringsToBuckets.lower_bound(NumStrings);
assert(Entry != StringsToBuckets.end());
return Entry->second;
OpenPOWER on IntegriCloud