diff options
| author | Quentin Colombet <qcolombet@apple.com> | 2016-04-08 00:50:58 +0000 |
|---|---|---|
| committer | Quentin Colombet <qcolombet@apple.com> | 2016-04-08 00:50:58 +0000 |
| commit | 2fbe04e93ded95b779c86af4241fcbd86366d7c8 (patch) | |
| tree | 7da90790f4b7423b3e7eb02c3f7014ae59cfe8cf /llvm | |
| parent | 5ce32728330fe7684f24d1b9c418c152db988830 (diff) | |
| download | bcm5719-llvm-2fbe04e93ded95b779c86af4241fcbd86366d7c8.tar.gz bcm5719-llvm-2fbe04e93ded95b779c86af4241fcbd86366d7c8.zip | |
[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
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/include/llvm/Target/TargetRegisterInfo.h | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/llvm/include/llvm/Target/TargetRegisterInfo.h b/llvm/include/llvm/Target/TargetRegisterInfo.h index 96842b3f952..48a0e0feb4a 100644 --- a/llvm/include/llvm/Target/TargetRegisterInfo.h +++ b/llvm/include/llvm/Target/TargetRegisterInfo.h @@ -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. |

