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
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