diff options
author | Daniel Jasper <djasper@google.com> | 2015-04-03 16:19:48 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2015-04-03 16:19:48 +0000 |
commit | efece52160095fb4837c51e304a23c22af860107 (patch) | |
tree | 9722452ac07bcf1e6847442e1bca0b5c488f2dba /llvm/lib/CodeGen | |
parent | f84bcf15c03e31c6409757a0e2cbc044117d94ce (diff) | |
download | bcm5719-llvm-efece52160095fb4837c51e304a23c22af860107.tar.gz bcm5719-llvm-efece52160095fb4837c51e304a23c22af860107.zip |
[MachineLICM] Small cleanup: Constify and rangeify.
NFC.
llvm-svn: 234018
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/MachineLICM.cpp | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/llvm/lib/CodeGen/MachineLICM.cpp b/llvm/lib/CodeGen/MachineLICM.cpp index 2f65a2ec25f..2fcfa3fc2fe 100644 --- a/llvm/lib/CodeGen/MachineLICM.cpp +++ b/llvm/lib/CodeGen/MachineLICM.cpp @@ -214,7 +214,8 @@ namespace { /// CanCauseHighRegPressure - Visit BBs from header to current BB, /// check if hoisting an instruction of the given cost matrix can cause high /// register pressure. - bool CanCauseHighRegPressure(DenseMap<unsigned, int> &Cost, bool Cheap); + bool CanCauseHighRegPressure(const DenseMap<unsigned, int> &Cost, + bool Cheap); /// UpdateBackTraceRegPressure - Traverse the back trace from header to /// the current block and update their register pressures to reflect the @@ -1125,27 +1126,23 @@ bool MachineLICM::IsCheapInstruction(MachineInstr &MI) const { /// CanCauseHighRegPressure - Visit BBs from header to current BB, check /// if hoisting an instruction of the given cost matrix can cause high /// register pressure. -bool MachineLICM::CanCauseHighRegPressure(DenseMap<unsigned, int> &Cost, +bool MachineLICM::CanCauseHighRegPressure(const DenseMap<unsigned, int>& Cost, bool CheapInstr) { - for (DenseMap<unsigned, int>::iterator CI = Cost.begin(), CE = Cost.end(); - CI != CE; ++CI) { - if (CI->second <= 0) + for (const auto &ClassAndCost : Cost) { + if (ClassAndCost.second <= 0) continue; - unsigned RCId = CI->first; - unsigned Limit = RegLimit[RCId]; - int Cost = CI->second; + unsigned Class = ClassAndCost.first; + int Limit = RegLimit[Class]; // Don't hoist cheap instructions if they would increase register pressure, // even if we're under the limit. if (CheapInstr && !HoistCheapInsts) return true; - for (unsigned i = BackTrace.size(); i != 0; --i) { - SmallVectorImpl<unsigned> &RP = BackTrace[i-1]; - if (RP[RCId] + Cost >= Limit) + for (const auto &RP : BackTrace) + if (static_cast<int>(RP[Class]) + ClassAndCost.second >= Limit) return true; - } } return false; |