From 1318364e3e95a0df24c607b478fab7034580618c Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Sat, 16 Aug 2014 01:54:34 +0000 Subject: 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 --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp') diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 7908524..66426c8 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 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 -- cgit v1.1