diff options
Diffstat (limited to 'llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp b/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp index 03f015f8c9e3..9c6487b40d60 100644 --- a/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp +++ b/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp @@ -63,6 +63,12 @@ static cl::opt<std::string> InteractiveChannelBaseName( "outgoing name should be " "<regalloc-evict-interactive-channel-base>.out")); +static cl::opt<unsigned> + MaxCascade("mlregalloc-max-cascade", cl::Hidden, + cl::desc("The maximum number of times a live range can be " + "evicted before preventing it from being evicted"), + cl::init(20)); + // Options that only make sense in development mode #ifdef LLVM_HAVE_TFLITE #include "RegAllocScore.h" @@ -554,7 +560,7 @@ private: std::unique_ptr<Logger> Log; }; -#endif //#ifdef LLVM_HAVE_TFLITE +#endif // #ifdef LLVM_HAVE_TFLITE } // namespace float MLEvictAdvisor::getInitialQueueSize(const MachineFunction &MF) { @@ -643,8 +649,18 @@ bool MLEvictAdvisor::loadInterferenceFeatures( RegClassInfo.getNumAllocatableRegs(MRI->getRegClass(VirtReg.reg())) < RegClassInfo.getNumAllocatableRegs( MRI->getRegClass(Intf->reg()))); - // Only evict older cascades or live ranges without a cascade. + unsigned IntfCascade = RA.getExtraInfo().getCascade(Intf->reg()); + // There is a potential that the model could be adversarial and + // continually evict live ranges over and over again, leading to a + // large amount of compile time being spent in regalloc. If we hit the + // threshold, prevent the range from being evicted. We still let the + // range through if it is urgent as we are required to produce an + // eviction if the candidate is not spillable. + if (IntfCascade >= MaxCascade && !Urgent) + return false; + + // Only evict older cascades or live ranges without a cascade. if (Cascade <= IntfCascade) { if (!Urgent) return false; |
