@@ -294,7 +294,7 @@ class MLEvictAdvisor : public RegAllocEvictionAdvisor {
294
294
FixedRegisters);
295
295
}
296
296
297
- const LIFeatureComponents
297
+ const LIFeatureComponents &
298
298
getLIFeatureComponents (const LiveInterval &LI) const ;
299
299
300
300
// Hold on to a default advisor for:
@@ -310,6 +310,9 @@ class MLEvictAdvisor : public RegAllocEvictionAdvisor {
310
310
// This could be static and shared, but its initialization is non-trivial.
311
311
std::bitset<FeatureIDs::FeatureCount> DoNotNormalize;
312
312
const float InitialQSize;
313
+
314
+ using RegID = unsigned ;
315
+ mutable DenseMap<RegID, LIFeatureComponents> CachedFeatures;
313
316
};
314
317
315
318
// ===================================
@@ -692,9 +695,15 @@ MCRegister MLEvictAdvisor::tryFindEvictionCandidate(
692
695
return Regs[CandidatePos].first ;
693
696
}
694
697
695
- const LIFeatureComponents
698
+ const LIFeatureComponents &
696
699
MLEvictAdvisor::getLIFeatureComponents (const LiveInterval &LI) const {
697
- LIFeatureComponents Ret;
700
+ RegID ID = LI.reg ().id ();
701
+ LIFeatureComponents Empty;
702
+ auto I = CachedFeatures.insert (std::make_pair (ID, Empty));
703
+ LIFeatureComponents &Ret = I.first ->getSecond ();
704
+ if (!I.second )
705
+ return Ret;
706
+
698
707
SmallPtrSet<MachineInstr *, 8 > Visited;
699
708
const TargetRegisterInfo &TRI = *MF.getSubtarget ().getRegisterInfo ();
700
709
@@ -775,7 +784,7 @@ void MLEvictAdvisor::extractFeatures(
775
784
776
785
if (LI.endIndex () > EndSI)
777
786
EndSI = LI.endIndex ();
778
- const LIFeatureComponents LIFC = getLIFeatureComponents (LI);
787
+ const LIFeatureComponents & LIFC = getLIFeatureComponents (LI);
779
788
NrBrokenHints += VRM->hasPreferredPhys (LI.reg ());
780
789
781
790
NrDefsAndUses += LIFC.NrDefsAndUses ;
0 commit comments