[llvm] r265763 - [TargetRegisterInfo] Fix BitMaskClassIterator::moveToNextID implementation.
Quentin Colombet via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 7 17:50:58 PDT 2016
Author: qcolombet
Date: Thu Apr 7 19:50:58 2016
New Revision: 265763
URL: http://llvm.org/viewvc/llvm-project?rev=265763&view=rev
Log:
[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.
Modified:
llvm/trunk/include/llvm/Target/TargetRegisterInfo.h
Modified: llvm/trunk/include/llvm/Target/TargetRegisterInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetRegisterInfo.h?rev=265763&r1=265762&r2=265763&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetRegisterInfo.h (original)
+++ llvm/trunk/include/llvm/Target/TargetRegisterInfo.h Thu Apr 7 19:50:58 2016
@@ -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.
More information about the llvm-commits
mailing list