BitSet::allocate() is being used with the expectation that it would
leave the bitfield untouched if its size hasn't changed, however,
the function always zeroed the last word, which led to obscure bugs
with live set computation.
This also fixes BitSet::resize(), which was broken, but luckily not
being used.
Cc: "10.2 10.3" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
ret && i <= func->loopNestingBound;
sequence = func->cfg.nextSequence(), ++i)
ret = buildLiveSets(BasicBlock::get(func->cfg.getRoot()));
+ // reset marker
+ for (ArrayList::Iterator bi = func->allBBlocks.iterator();
+ !bi.end(); bi.next())
+ BasicBlock::get(bi)->liveSet.marker = false;
if (!ret)
break;
func->orderInstructions(this->insns);
return false;
}
if (n > p)
- memset(&data[4 * p + 4], 0, (n - p) * 4);
+ memset(&data[p], 0, (n - p) * 4);
+ if (nBits < size && (nBits % 32))
+ data[(nBits + 31) / 32 - 1] &= (1 << (nBits % 32)) - 1;
size = nBits;
return true;
if (zero)
memset(data, 0, (size + 7) / 8);
else
- if (nBits)
- data[(size + 31) / 32 - 1] = 0; // clear unused bits (e.g. for popCount)
+ if (size % 32) // clear unused bits (e.g. for popCount)
+ data[(size + 31) / 32 - 1] &= (1 << (size % 32)) - 1;
return data;
}
FREE(data);
}
+ // allocate will keep old data iff size is unchanged
bool allocate(unsigned int nBits, bool zero);
bool resize(unsigned int nBits); // keep old data, zero additional bits