[lld] r308497 - [PDB] Emit TPI and IPI hashes
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 19 10:26:07 PDT 2017
Author: rnk
Date: Wed Jul 19 10:26:07 2017
New Revision: 308497
URL: http://llvm.org/viewvc/llvm-project?rev=308497&view=rev
Log:
[PDB] Emit TPI and IPI hashes
Modified:
lld/trunk/COFF/PDB.cpp
lld/trunk/test/COFF/pdb.test
Modified: lld/trunk/COFF/PDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/PDB.cpp?rev=308497&r1=308496&r2=308497&view=diff
==============================================================================
--- lld/trunk/COFF/PDB.cpp (original)
+++ lld/trunk/COFF/PDB.cpp Wed Jul 19 10:26:07 2017
@@ -34,6 +34,7 @@
#include "llvm/DebugInfo/PDB/Native/PDBFile.h"
#include "llvm/DebugInfo/PDB/Native/PDBFileBuilder.h"
#include "llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h"
+#include "llvm/DebugInfo/PDB/Native/TpiHashing.h"
#include "llvm/DebugInfo/PDB/Native/TpiStream.h"
#include "llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h"
#include "llvm/DebugInfo/PDB/PDB.h"
@@ -163,10 +164,15 @@ static void addTypeInfo(pdb::TpiStreamBu
// Start the TPI or IPI stream header.
TpiBuilder.setVersionHeader(pdb::PdbTpiV80);
- // Flatten the in memory type table.
+ // Flatten the in memory type table and hash each type.
TypeTable.ForEachRecord([&](TypeIndex TI, ArrayRef<uint8_t> Rec) {
- // FIXME: Hash types.
- TpiBuilder.addTypeRecord(Rec, None);
+ assert(Rec.size() >= sizeof(RecordPrefix));
+ const RecordPrefix *P = reinterpret_cast<const RecordPrefix *>(Rec.data());
+ CVType Type(static_cast<TypeLeafKind>(unsigned(P->RecordKind)), Rec);
+ auto Hash = pdb::hashTypeRecord(Type);
+ if (auto E = Hash.takeError())
+ fatal("type hashing error");
+ TpiBuilder.addTypeRecord(Rec, *Hash);
});
}
Modified: lld/trunk/test/COFF/pdb.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/pdb.test?rev=308497&r1=308496&r2=308497&view=diff
==============================================================================
--- lld/trunk/test/COFF/pdb.test (original)
+++ lld/trunk/test/COFF/pdb.test Wed Jul 19 10:26:07 2017
@@ -7,7 +7,7 @@
# RUN: -dbi-stream -ipi-stream -tpi-stream %t.pdb | FileCheck %s
# RUN: llvm-pdbutil dump -modules -section-map -section-contribs \
-# RUN: -types -ids %t.pdb | FileCheck -check-prefix RAW %s
+# RUN: -types -ids -type-extras -id-extras %t.pdb | FileCheck -check-prefix RAW %s
# CHECK: MSF:
# CHECK-NEXT: SuperBlock:
@@ -132,40 +132,40 @@ RAW-NEXT: pdb file ni: 1 `{
RAW: Types (TPI Stream)
RAW-NEXT: ============================================================
RAW-NEXT: Showing 5 records
-RAW-NEXT: 0x1000 | LF_ARGLIST [size = 8]
-RAW-NEXT: 0x1001 | LF_PROCEDURE [size = 16]
+RAW-NEXT: 0x1000 | LF_ARGLIST [size = 8, hash = 0xEC0]
+RAW-NEXT: 0x1001 | LF_PROCEDURE [size = 16, hash = 0x7BC]
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]
+RAW-NEXT: 0x1002 | LF_POINTER [size = 12, hash = 0x884]
RAW-NEXT: referent = 0x1001, mode = pointer, opts = None, kind = ptr64
-RAW-NEXT: 0x1003 | LF_ARGLIST [size = 12]
+RAW-NEXT: 0x1003 | LF_ARGLIST [size = 12, hash = 0x936]
RAW-NEXT: <no type>: ``
-RAW-NEXT: 0x1004 | LF_PROCEDURE [size = 16]
+RAW-NEXT: 0x1004 | LF_PROCEDURE [size = 16, hash = 0x852]
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]
+RAW-NEXT: 0x1000 | LF_FUNC_ID [size = 20, hash = 0x330]
RAW-NEXT: name = main, type = 0x1004, parent scope = <no type>
-RAW-NEXT: 0x1001 | LF_FUNC_ID [size = 16]
+RAW-NEXT: 0x1001 | LF_FUNC_ID [size = 16, hash = 0x120]
RAW-NEXT: name = foo, type = 0x1001, parent scope = <no type>
-RAW-NEXT: 0x1002 | LF_STRING_ID [size = 16] ID: <no type>, String: D:\b
-RAW-NEXT: 0x1003 | LF_STRING_ID [size = 36] ID: <no type>, String: C:\vs14\VC\BIN\amd64\cl.exe
-RAW-NEXT: 0x1004 | LF_STRING_ID [size = 260] 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]
+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: 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] 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] ID: <no type>, String: ret42-main.c
-RAW-NEXT: 0x1008 | LF_STRING_ID [size = 24] ID: <no type>, String: D:\b\vc140.pdb
-RAW-NEXT: 0x1009 | LF_BUILDINFO [size = 28]
+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: 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] ID: <no type>, String: ret42-sub.c
-RAW-NEXT: 0x100B | LF_BUILDINFO [size = 28]
+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: 0x1002: `D:\b`
RAW-NEXT: 0x1003: `C:\vs14\VC\BIN\amd64\cl.exe`
RAW-NEXT: 0x100A: `ret42-sub.c`
More information about the llvm-commits
mailing list