[PDB] Increase TPI hash bucket count.

PDBs contain several serialized hash tables. In the microsoft-pdb
repo published to support LLVM implementing PDB support, the
provided initializes the bucket count for the TPI and IPI streams
to the maximum size. This occurs in tpi.cpp L33 and tpi.cpp L398.
In the LLVM code for generating PDBs, these streams are created with
minimum number of buckets. This difference makes LLVM generated
PDBs slower for when used for debugging.

Patch by C.J. Hebert
Differential Revision: https://reviews.llvm.org/D56942

llvm-svn: 352117
This commit is contained in:
Zachary Turner 2019-01-24 22:25:55 +00:00
parent a228ab524f
commit 8371da385a
4 changed files with 44 additions and 19 deletions
lld/test/COFF
llvm
lib/DebugInfo/PDB/Native
tools/llvm-pdbutil

View File

@ -0,0 +1,10 @@
# RUN: yaml2obj < %p/Inputs/pdb1.yaml > %t1.obj
# RUN: yaml2obj < %p/Inputs/pdb2.yaml > %t2.obj
# RUN: rm -f %t.dll %t.pdb
# RUN: lld-link /debug /pdb:%t.pdb /dll /out:%t.dll \
# RUN: /entry:main /nodefaultlib %t1.obj %t2.obj
# RUN: llvm-pdbutil dump -types -type-extras %t.pdb | FileCheck %s
CHECK: Hash Key Size: 4
CHECK-NEXT: Num Hash Buckets: 262143

View File

@ -142,40 +142,40 @@ RAW-NEXT: pdb file ni: 1 `{{.*pdb.test.tmp.pdb}}`, src file ni: 0 `
RAW: Types (TPI Stream)
RAW-NEXT: ============================================================
RAW-NEXT: Showing 5 records
RAW-NEXT: 0x1000 | LF_ARGLIST [size = 8, hash = 0xEC0]
RAW-NEXT: 0x1001 | LF_PROCEDURE [size = 16, hash = 0x7BC]
RAW-NEXT: 0x1000 | LF_ARGLIST [size = 8, hash = 0x32484]
RAW-NEXT: 0x1001 | LF_PROCEDURE [size = 16, hash = 0x27EE9]
RAW-NEXT: return type = 0x0074 (int), # args = 0, param list = 0x1000
RAW-NEXT: calling conv = cdecl, options = None
RAW-NEXT: 0x1002 | LF_POINTER [size = 12, hash = 0x884]
RAW-NEXT: 0x1002 | LF_POINTER [size = 12, hash = 0x39732]
RAW-NEXT: referent = 0x1001, mode = pointer, opts = None, kind = ptr64
RAW-NEXT: 0x1003 | LF_ARGLIST [size = 12, hash = 0x936]
RAW-NEXT: 0x1003 | LF_ARGLIST [size = 12, hash = 0x1FC10]
RAW-NEXT: <no type>: ``
RAW-NEXT: 0x1004 | LF_PROCEDURE [size = 16, hash = 0x852]
RAW-NEXT: 0x1004 | LF_PROCEDURE [size = 16, hash = 0x1BD3]
RAW-NEXT: return type = 0x0074 (int), # args = 0, param list = 0x1003
RAW-NEXT: calling conv = cdecl, options = None
RAW: Types (IPI Stream)
RAW-NEXT: ============================================================
RAW-NEXT: Showing 12 records
RAW-NEXT: 0x1000 | LF_FUNC_ID [size = 20, hash = 0x330]
RAW-NEXT: 0x1000 | LF_FUNC_ID [size = 20, hash = 0x38E5A]
RAW-NEXT: name = main, type = 0x1004, parent scope = <no type>
RAW-NEXT: 0x1001 | LF_FUNC_ID [size = 16, hash = 0x120]
RAW-NEXT: 0x1001 | LF_FUNC_ID [size = 16, hash = 0xD08E]
RAW-NEXT: name = foo, type = 0x1001, parent scope = <no type>
RAW-NEXT: 0x1002 | LF_STRING_ID [size = 16, hash = 0x757] ID: <no type>, String: D:\b
RAW-NEXT: 0x1003 | LF_STRING_ID [size = 36, hash = 0xC3A] ID: <no type>, String: C:\vs14\VC\BIN\amd64\cl.exe
RAW-NEXT: 0x1004 | LF_STRING_ID [size = 260, hash = 0x433] ID: <no type>, String: -Z7 -c -MT -IC:\vs14\VC\INCLUDE -IC:\vs14\VC\ATLMFC\INCLUDE -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.10150.0\ucrt" -I"C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include\um" -I"C:\Program Files (x86)\Windows Kits\8.1\include\shared"
RAW-NEXT: 0x1005 | LF_SUBSTR_LIST [size = 12, hash = 0x759]
RAW-NEXT: 0x1002 | LF_STRING_ID [size = 16, hash = 0x3EBD9] ID: <no type>, String: D:\b
RAW-NEXT: 0x1003 | LF_STRING_ID [size = 36, hash = 0xD327] ID: <no type>, String: C:\vs14\VC\BIN\amd64\cl.exe
RAW-NEXT: 0x1004 | LF_STRING_ID [size = 260, hash = 0x2FA6A] ID: <no type>, String: -Z7 -c -MT -IC:\vs14\VC\INCLUDE -IC:\vs14\VC\ATLMFC\INCLUDE -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.10150.0\ucrt" -I"C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include\um" -I"C:\Program Files (x86)\Windows Kits\8.1\include\shared"
RAW-NEXT: 0x1005 | LF_SUBSTR_LIST [size = 12, hash = 0x6053]
RAW-NEXT: 0x1004: `-Z7 -c -MT -IC:\vs14\VC\INCLUDE -IC:\vs14\VC\ATLMFC\INCLUDE -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.10150.0\ucrt" -I"C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include\um" -I"C:\Program Files (x86)\Windows Kits\8.1\include\shared"`
RAW-NEXT: 0x1006 | LF_STRING_ID [size = 132, hash = 0xF57] ID: 0x1005, String: -I"C:\Program Files (x86)\Windows Kits\8.1\include\um" -I"C:\Program Files (x86)\Windows Kits\8.1\include\winrt" -TC -X
RAW-NEXT: 0x1007 | LF_STRING_ID [size = 24, hash = 0x2D1] ID: <no type>, String: ret42-main.c
RAW-NEXT: 0x1008 | LF_STRING_ID [size = 24, hash = 0xB8B] ID: <no type>, String: D:\b\vc140.pdb
RAW-NEXT: 0x1009 | LF_BUILDINFO [size = 28, hash = 0xA8C]
RAW-NEXT: 0x1006 | LF_STRING_ID [size = 132, hash = 0xCAC7] ID: 0x1005, String: -I"C:\Program Files (x86)\Windows Kits\8.1\include\um" -I"C:\Program Files (x86)\Windows Kits\8.1\include\winrt" -TC -X
RAW-NEXT: 0x1007 | LF_STRING_ID [size = 24, hash = 0x21783] ID: <no type>, String: ret42-main.c
RAW-NEXT: 0x1008 | LF_STRING_ID [size = 24, hash = 0x1DB87] ID: <no type>, String: D:\b\vc140.pdb
RAW-NEXT: 0x1009 | LF_BUILDINFO [size = 28, hash = 0x5E91]
RAW-NEXT: 0x1002: `D:\b`
RAW-NEXT: 0x1003: `C:\vs14\VC\BIN\amd64\cl.exe`
RAW-NEXT: 0x1007: `ret42-main.c`
RAW-NEXT: 0x1008: `D:\b\vc140.pdb`
RAW-NEXT: 0x1006: ` -I"C:\Program Files (x86)\Windows Kits\8.1\include\um" -I"C:\Program Files (x86)\Windows Kits\8.1\include\winrt" -TC -X`
RAW-NEXT: 0x100A | LF_STRING_ID [size = 20, hash = 0x39C] ID: <no type>, String: ret42-sub.c
RAW-NEXT: 0x100B | LF_BUILDINFO [size = 28, hash = 0xAD7]
RAW-NEXT: 0x100A | LF_STRING_ID [size = 20, hash = 0x7C68] ID: <no type>, String: ret42-sub.c
RAW-NEXT: 0x100B | LF_BUILDINFO [size = 28, hash = 0x254D2]
RAW-NEXT: 0x1002: `D:\b`
RAW-NEXT: 0x1003: `C:\vs14\VC\BIN\amd64\cl.exe`
RAW-NEXT: 0x100A: `ret42-sub.c`

View File

@ -76,7 +76,7 @@ Error TpiStreamBuilder::finalize() {
H->HashStreamIndex = HashStreamIndex;
H->HashAuxStreamIndex = kInvalidStreamIndex;
H->HashKeySize = sizeof(ulittle32_t);
H->NumHashBuckets = MinTpiHashBuckets;
H->NumHashBuckets = MaxTpiHashBuckets - 1;
// Recall that hash values go into a completely different stream identified by
// the `HashStreamIndex` field of the `TpiStreamHeader`. Therefore, the data
@ -129,7 +129,7 @@ Error TpiStreamBuilder::finalizeMsfLayout() {
ulittle32_t *H = Allocator.Allocate<ulittle32_t>(TypeHashes.size());
MutableArrayRef<ulittle32_t> HashBuffer(H, TypeHashes.size());
for (uint32_t I = 0; I < TypeHashes.size(); ++I) {
HashBuffer[I] = TypeHashes[I] % MinTpiHashBuckets;
HashBuffer[I] = TypeHashes[I] % (MaxTpiHashBuckets - 1);
}
ArrayRef<uint8_t> Bytes(
reinterpret_cast<const uint8_t *>(HashBuffer.data()),

View File

@ -1412,6 +1412,21 @@ Error DumpOutputStyle::dumpTpiStream(uint32_t StreamIdx) {
if (DumpExtras) {
P.NewLine();
support::ulittle32_t Version;
support::ulittle16_t HashStreamIndex;
support::ulittle16_t HashAuxStreamIndex;
support::ulittle32_t HashKeySize;
support::ulittle32_t NumHashBuckets;
P.formatLine("Header Version: {0}",
static_cast<uint32_t>(Stream.getTpiVersion()));
P.formatLine("Hash Stream Index: {0}", Stream.getTypeHashStreamIndex());
P.formatLine("Aux Hash Stream Index: {0}",
Stream.getTypeHashStreamAuxIndex());
P.formatLine("Hash Key Size: {0}", Stream.getHashKeySize());
P.formatLine("Num Hash Buckets: {0}", Stream.getNumHashBuckets());
auto IndexOffsets = Stream.getTypeIndexOffsets();
P.formatLine("Type Index Offsets:");
for (const auto &IO : IndexOffsets) {