diff options
author | Zachary Turner <zturner@google.com> | 2018-10-09 21:19:03 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2018-10-09 21:19:03 +0000 |
commit | 5989281cf3af52fc07ad458297e70f559db02de7 (patch) | |
tree | 518abc70020754a438f1f9ab92c921f4bd178968 /llvm/lib/DebugInfo/PDB | |
parent | 5e49846ca60ceafad396f30fd545221199ca0af7 (diff) | |
download | bcm5719-llvm-5989281cf3af52fc07ad458297e70f559db02de7.tar.gz bcm5719-llvm-5989281cf3af52fc07ad458297e70f559db02de7.zip |
[PDB] Fix another bug in globals stream name lookup.
When we're on the last bucket the computation is tricky.
We were failing when the last bucket contained multiple
matches. Added a new test for this.
llvm-svn: 344081
Diffstat (limited to 'llvm/lib/DebugInfo/PDB')
-rw-r--r-- | llvm/lib/DebugInfo/PDB/Native/GlobalsStream.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Native/GlobalsStream.cpp b/llvm/lib/DebugInfo/PDB/Native/GlobalsStream.cpp index b03c6c3bf81..e3631956682 100644 --- a/llvm/lib/DebugInfo/PDB/Native/GlobalsStream.cpp +++ b/llvm/lib/DebugInfo/PDB/Native/GlobalsStream.cpp @@ -56,22 +56,28 @@ GlobalsStream::findRecordsByName(StringRef Name, if (CompressedBucketIndex == -1) return Result; - uint32_t ChainStartOffset = GlobalsTable.HashBuckets[CompressedBucketIndex]; - uint32_t NextChainOffset = GlobalsTable.HashBuckets.size() * 12; uint32_t LastBucketIndex = GlobalsTable.HashBuckets.size() - 1; - if (static_cast<uint32_t>(CompressedBucketIndex) < LastBucketIndex) { - NextChainOffset = GlobalsTable.HashBuckets[CompressedBucketIndex + 1]; + uint32_t StartRecordIndex = + GlobalsTable.HashBuckets[CompressedBucketIndex] / 12; + uint32_t EndRecordIndex = 0; + if (LLVM_LIKELY(uint32_t(CompressedBucketIndex) < LastBucketIndex)) { + EndRecordIndex = GlobalsTable.HashBuckets[CompressedBucketIndex + 1]; + } else { + // If this is the last bucket, it consists of all hash records until the end + // of the HashRecords array. + EndRecordIndex = GlobalsTable.HashRecords.size() * 12; } - ChainStartOffset /= 12; - NextChainOffset /= 12; - while (ChainStartOffset < NextChainOffset) { - PSHashRecord PSH = GlobalsTable.HashRecords[ChainStartOffset]; + EndRecordIndex /= 12; + + assert(EndRecordIndex <= GlobalsTable.HashRecords.size()); + while (StartRecordIndex < EndRecordIndex) { + PSHashRecord PSH = GlobalsTable.HashRecords[StartRecordIndex]; uint32_t Off = PSH.Off - 1; codeview::CVSymbol Record = Symbols.readRecord(Off); if (codeview::getSymbolName(Record) == Name) Result.push_back(std::make_pair(Off, std::move(Record))); - ++ChainStartOffset; + ++StartRecordIndex; } return Result; } |