[llvm] [GreedyRA]: Add flag to force local assignment heuristics (PR #102160)

Jeffrey Byrnes via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 6 10:39:55 PDT 2024


================
@@ -321,10 +327,12 @@ unsigned DefaultPriorityAdvisor::getPriority(const LiveInterval &LI) const {
     // Giant live ranges fall back to the global assignment heuristic, which
     // prevents excessive spilling in pathological cases.
     const TargetRegisterClass &RC = *MRI->getRegClass(Reg);
-    bool ForceGlobal = RC.GlobalPriority ||
-                       (!ReverseLocalAssignment &&
-                        (Size / SlotIndex::InstrDist) >
-                            (2 * RegClassInfo.getNumAllocatableRegs(&RC)));
+
+    bool ForceGlobal =
+        RC.GlobalPriority ||
+        (!GreedyForceLocalAssignment && !ReverseLocalAssignment &&
+         (Size / SlotIndex::InstrDist) >
+             (2 * RegClassInfo.getNumAllocatableRegs(&RC)));
----------------
jrbyrnes wrote:

My plan is to use this flag to skip, and in separate PR introduce TRI.forceGlobalAssignment which gives targets a chance to write their own. Other targets may be fine with the current implementation (backend has limited calls to SlotIndex renumbering, minimal overlapping regs), and universally changing could cause regressions or increase compile time for no reason.

Even if we fix the heuristic, there are still edge cases where we would like to override

https://github.com/llvm/llvm-project/pull/102160


More information about the llvm-commits mailing list