From: Duncan P. N. Exon Smith Date: Sat, 16 Aug 2014 01:54:34 +0000 (+0000) Subject: UseListOrder: Correctly count the number of uses X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=1e97329f2725fb5b5e88f7be99da07da6cf9fe62;p=oota-llvm.git 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215804 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 79085248770..66426c83c66 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/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