[TargetRegisterInfo] Fix BitMaskClassIterator::moveToNextID implementation.

Make sure we do not read past the size of the mask. Although we were not using
the value read, this is bad and makes ASan complain.

llvm-svn: 265763
This commit is contained in:
Quentin Colombet 2016-04-08 00:50:58 +00:00
parent 5ce3272833
commit 2fbe04e93d
1 changed files with 6 additions and 7 deletions

View File

@ -987,17 +987,16 @@ class BitMaskClassIterator {
// If the current chunk of memory is empty, move to the next one,
// while making sure we do not go pass the number of register
// classes.
while (!CurrentChunk && Base < NumRegClasses) {
while (!CurrentChunk) {
// Move to the next chunk.
CurrentChunk = *++Mask;
Base += 32;
if (Base >= NumRegClasses) {
ID = NumRegClasses;
return;
}
CurrentChunk = *++Mask;
Idx = Base;
}
// The mask is empty now.
if (!CurrentChunk || Base >= NumRegClasses) {
ID = NumRegClasses;
return;
}
// Otherwise look for the first bit set from the right
// (representation of the class ID is big endian).
// See getSubClassMask for more details on the representation.