[llvm] r215804 - UseListOrder: Correctly count the number of uses

Duncan P. N. Exon Smith dexonsmith at apple.com
Fri Aug 15 18:54:34 PDT 2014


Author: dexonsmith
Date: Fri Aug 15 20:54:34 2014
New Revision: 215804

URL: http://llvm.org/viewvc/llvm-project?rev=215804&view=rev
Log:
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.

Modified:
    llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp

Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=215804&r1=215803&r2=215804&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Fri Aug 15 20:54:34 2014
@@ -1697,9 +1697,9 @@ std::error_code BitcodeReader::ParseUseL
       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





More information about the llvm-commits mailing list