diff options
| author | Michael Kruse <llvm-project@meinersbur.de> | 2025-01-03 10:22:51 +0100 |
|---|---|---|
| committer | Michael Kruse <llvm-project@meinersbur.de> | 2025-01-03 10:22:51 +0100 |
| commit | 38500d63e14ce340236840f60d356cdefb56a52c (patch) | |
| tree | 17edbec446ce9b50d2f215a483b83afb293a635d /llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp | |
| parent | 1a3d5daaef7a6a63448a497da3eff7fc9e23df26 (diff) | |
| parent | 27f30029741ecf023baece7b3dde1ff9011ffefc (diff) | |
Merge branch 'main' into users/meinersbur/flang_runtime_split-headersusers/meinersbur/flang_runtime_split-headers
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; |
