diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-08-16 01:54:34 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-08-16 01:54:34 +0000 |
commit | 1318364e3e95a0df24c607b478fab7034580618c (patch) | |
tree | ccf90d57465af0d335b777509a66e0ca1442cbfa /llvm/lib/Bitcode/Reader/BitcodeReader.cpp | |
parent | 0c39d40c8b1e3ef028b4082593896e24633a66d7 (diff) | |
download | bcm5719-llvm-1318364e3e95a0df24c607b478fab7034580618c.tar.gz bcm5719-llvm-1318364e3e95a0df24c607b478fab7034580618c.zip |
UseListOrder: Correctly count the number of uses
This is an off-by-one bug I found by inspection, which would only
trigger if the bitcode writer sees more uses of a `Value` than the
reader. Since this is only relevant when an instruction gets upgraded
somehow, there unfortunately isn't a reasonable way to add test
coverage.
llvm-svn: 215804
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 79085248770..66426c83c66 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1697,9 +1697,9 @@ std::error_code BitcodeReader::ParseUseLists() { unsigned NumUses = 0; SmallDenseMap<const Use *, unsigned, 16> Order; for (const Use &U : V->uses()) { - if (NumUses > Record.size()) + if (++NumUses > Record.size()) break; - Order[&U] = Record[NumUses++]; + Order[&U] = Record[NumUses - 1]; } if (Order.size() != Record.size() || NumUses > Record.size()) // Mismatches can happen if the functions are being materialized lazily |