FixedRegisters);
}
- const LIFeatureComponents
+ const LIFeatureComponents &
getLIFeatureComponents(const LiveInterval &LI) const;
// Hold on to a default advisor for:
// This could be static and shared, but its initialization is non-trivial.
std::bitset<FeatureIDs::FeatureCount> DoNotNormalize;
const float InitialQSize;
+
+ using RegID = unsigned;
+ mutable DenseMap<RegID, LIFeatureComponents> CachedFeatures;
};
// ===================================
return Regs[CandidatePos].first;
}
-const LIFeatureComponents
+const LIFeatureComponents &
MLEvictAdvisor::getLIFeatureComponents(const LiveInterval &LI) const {
- LIFeatureComponents Ret;
+ RegID ID = LI.reg().id();
+ LIFeatureComponents Empty;
+ auto I = CachedFeatures.insert(std::make_pair(ID, Empty));
+ LIFeatureComponents &Ret = I.first->getSecond();
+ if (!I.second)
+ return Ret;
+
SmallPtrSet<MachineInstr *, 8> Visited;
const TargetRegisterInfo &TRI = *MF.getSubtarget().getRegisterInfo();
if (LI.endIndex() > EndSI)
EndSI = LI.endIndex();
- const LIFeatureComponents LIFC = getLIFeatureComponents(LI);
+ const LIFeatureComponents &LIFC = getLIFeatureComponents(LI);
NrBrokenHints += VRM->hasPreferredPhys(LI.reg());
NrDefsAndUses += LIFC.NrDefsAndUses;