]> granicus.if.org Git - llvm/commit
[PDB] Fix hash function used to write /src/headerblock
authorNico Weber <nicolasweber@gmx.de>
Mon, 29 Apr 2019 23:09:35 +0000 (23:09 +0000)
committerNico Weber <nicolasweber@gmx.de>
Mon, 29 Apr 2019 23:09:35 +0000 (23:09 +0000)
commit033bb22f7981e64cb4b97030b09324a5ae9742d0
tree7fb3593079187b2077fc8a4b629ab28c08794765
parent45db55e52e49f63cedab573ac7c89969c315e1a8
[PDB] Fix hash function used to write /src/headerblock

lld-link used to write PDB files that DIA couldn't recover natvis
files from if:

- The global strings table was > 64kiB
- There were at least 3 natvis files

The cause was that the hash function for the /src/headerblock stream
was incorrect: It needs to be truncated to 16 bit.

If the global strings table was <= 64kiB, truncating to 16 bit is a
no-op, so this wasn't needed for small programs.

If there are only 1 or 2 natvis files, then the growth strategy in
HashTable::grow() would mean the hash table would have 2 buckets (for 1
natvis file) or 4 buckets (for 4 natvis files), and since the hash
function is used modulo number of buckets, and since 2 and 4 divide
0x10000, the missing `% 0x10000` is a no-op there too. For 3 natvis
files, the hash table grows to 6 buckets, which has a factor that's not
common with 0x10000 and the difference starts to matter.

Fixes PR41626.

Differential Revision: https://reviews.llvm.org/D61277

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359515 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/DebugInfo/PDB/Native/HashTable.h
lib/DebugInfo/PDB/Native/NamedStreamMap.cpp
lib/DebugInfo/PDB/Native/PDBStringTableBuilder.cpp
unittests/DebugInfo/PDB/StringTableBuilderTest.cpp