1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

RegisterPressure: Hide non-const iterators of PressureDiff

It is too easy to accidentally violate the ordering requirements when
modifying the PressureDiff entries through iterators.

llvm-svn: 250590
This commit is contained in:
Matthias Braun 2015-10-17 00:08:48 +00:00
parent 9dcf26ed04
commit cfaf06e08d
2 changed files with 6 additions and 4 deletions

View File

@ -125,11 +125,13 @@ class PressureDiff {
enum { MaxPSets = 16 };
PressureChange PressureChanges[MaxPSets];
public:
typedef PressureChange* iterator;
iterator nonconst_begin() { return &PressureChanges[0]; }
iterator nonconst_end() { return &PressureChanges[MaxPSets]; }
public:
typedef const PressureChange* const_iterator;
iterator begin() { return &PressureChanges[0]; }
iterator end() { return &PressureChanges[MaxPSets]; }
const_iterator begin() const { return &PressureChanges[0]; }
const_iterator end() const { return &PressureChanges[MaxPSets]; }

View File

@ -389,7 +389,7 @@ void PressureDiff::addPressureChange(unsigned RegUnit, bool IsDec,
int Weight = IsDec ? -PSetI.getWeight() : PSetI.getWeight();
for (; PSetI.isValid(); ++PSetI) {
// Find an existing entry in the pressure diff for this PSet.
PressureDiff::iterator I = begin(), E = end();
PressureDiff::iterator I = nonconst_begin(), E = nonconst_end();
for (; I != E && I->isValid(); ++I) {
if (I->getPSet() >= *PSetI)
break;