summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2018-03-15 22:31:00 +0000
committerZachary Turner <zturner@google.com>2018-03-15 22:31:00 +0000
commitedbcbe0b62d6bfe729eeb6b7adb6d3a316a332e7 (patch)
treed66d46864cf0defeecf62c1a216580c45068a3b9 /llvm/lib
parent92e6fbf54aabaf82bb4457ece3e85316cf38a505 (diff)
downloadbcm5719-llvm-edbcbe0b62d6bfe729eeb6b7adb6d3a316a332e7.tar.gz
bcm5719-llvm-edbcbe0b62d6bfe729eeb6b7adb6d3a316a332e7.zip
[PDB] Fix a bug where we were serializing hash tables incorrectly.
There was some code that tried to calculate the number of 4-byte words required to hold N bits, but it was instead computing the number of bytes required to hold N bits. This was leading to extraneous data being output into the hash table, which would cause certain operations in DIA (the Microsoft PDB reader) to fail. llvm-svn: 327675
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/HashTable.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Native/HashTable.cpp b/llvm/lib/DebugInfo/PDB/Native/HashTable.cpp
index 5ed0acc8fd7..cfabc9cd1ad 100644
--- a/llvm/lib/DebugInfo/PDB/Native/HashTable.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/HashTable.cpp
@@ -46,16 +46,18 @@ Error llvm::pdb::readSparseBitVector(BinaryStreamReader &Stream,
Error llvm::pdb::writeSparseBitVector(BinaryStreamWriter &Writer,
SparseBitVector<> &Vec) {
+ constexpr int BitsPerWord = 8 * sizeof(uint32_t);
+
int ReqBits = Vec.find_last() + 1;
- uint32_t NumWords = alignTo(ReqBits, sizeof(uint32_t)) / sizeof(uint32_t);
- if (auto EC = Writer.writeInteger(NumWords))
+ uint32_t ReqWords = alignTo(ReqBits, BitsPerWord) / BitsPerWord;
+ if (auto EC = Writer.writeInteger(ReqWords))
return joinErrors(
std::move(EC),
make_error<RawError>(raw_error_code::corrupt_file,
"Could not write linear map number of words"));
uint32_t Idx = 0;
- for (uint32_t I = 0; I != NumWords; ++I) {
+ for (uint32_t I = 0; I != ReqWords; ++I) {
uint32_t Word = 0;
for (uint32_t WordIdx = 0; WordIdx < 32; ++WordIdx, ++Idx) {
if (Vec.test(Idx))
OpenPOWER on IntegriCloud