@@ -63,11 +63,11 @@ static cl::opt<std::string> InteractiveChannelBaseName(
6363 " outgoing name should be "
6464 " <regalloc-evict-interactive-channel-base>.out" ));
6565
66- static cl::opt<unsigned > MaxEvictionCount (
67- " mlregalloc-max-eviction-count " , cl::Hidden,
68- cl::desc (" The maximum number of times a live range can be "
69- " evicted before preventing it from being evicted" ),
70- cl::init(100 ));
66+ static cl::opt<unsigned >
67+ MaxCascade ( " mlregalloc-max-cascade " , cl::Hidden,
68+ cl::desc (" The maximum number of times a live range can be "
69+ " evicted before preventing it from being evicted" ),
70+ cl::init(20 ));
7171
7272// Options that only make sense in development mode
7373#ifdef LLVM_HAVE_TFLITE
@@ -364,22 +364,6 @@ class MLEvictAdvisor : public RegAllocEvictionAdvisor {
364364
365365 using RegID = unsigned ;
366366 mutable DenseMap<RegID, LIFeatureComponents> CachedFeatures;
367-
368- mutable std::unordered_map<unsigned , unsigned > VirtRegEvictionCounts;
369-
370- void onEviction (Register RegBeingEvicted) const {
371- // If we cannot find the virtual register in the map, we just assume it has
372- // not been evicted before and thus has a value of zero (which is what the
373- // subscript operator returns by default).
374- ++VirtRegEvictionCounts[RegBeingEvicted.id ()];
375- }
376-
377- unsigned getEvictionCount (Register Reg) const {
378- auto EvictionCountIt = VirtRegEvictionCounts.find (Reg.id ());
379- if (EvictionCountIt != VirtRegEvictionCounts.end ())
380- return EvictionCountIt->second ;
381- return 0 ;
382- }
383367};
384368
385369#define _DECL_FEATURES (type, name, shape, _ ) \
@@ -673,7 +657,7 @@ bool MLEvictAdvisor::loadInterferenceFeatures(
673657 // threshold, prevent the range from being evicted. We still let the
674658 // range through if it is urgent as we are required to produce an
675659 // eviction if the candidate is not spillable.
676- if (getEvictionCount (Intf-> reg ()) > MaxEvictionCount && !Urgent)
660+ if (IntfCascade >= MaxCascade && !Urgent)
677661 return false ;
678662
679663 // Only evict older cascades or live ranges without a cascade.
@@ -819,22 +803,6 @@ MCRegister MLEvictAdvisor::tryFindEvictionCandidate(
819803 }
820804 assert (CandidatePos < ValidPosLimit);
821805 (void )ValidPosLimit;
822-
823- // Update information about how many times the virtual registers being
824- // evicted have been evicted so that we can prevent the model from evicting
825- // the same ranges continually and eating compile time.
826- if (CandidatePos == CandidateVirtRegPos) {
827- onEviction (VirtReg.reg ());
828- } else {
829- for (MCRegUnit Unit : TRI->regunits (Regs[CandidatePos].first )) {
830- LiveIntervalUnion::Query &Q = Matrix->query (VirtReg, Unit);
831- const auto &IFIntervals = Q.interferingVRegs (EvictInterferenceCutoff);
832- for (const LiveInterval *Intf : reverse (IFIntervals)) {
833- onEviction (Intf->reg ());
834- }
835- }
836- }
837-
838806 return Regs[CandidatePos].first ;
839807}
840808
0 commit comments