[llvm] [RegAlloc] Change the computation of CSRCost (PR #177226)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 21 11:57:11 PST 2026


================
@@ -2339,6 +2345,31 @@ MCRegister RAGreedy::selectOrSplit(const LiveInterval &VirtReg,
   return Reg;
 }
 
+/// calcSpillCost - Compute how expensive it would be to spill the live range in
+/// LI into memory.
+BlockFrequency RAGreedy::calcSpillCost(const LiveInterval &LI) {
+  uint64_t SpillCost = 0;
+  SmallPtrSet<MachineInstr *, 8> Visited;
+
+  for (MachineRegisterInfo::reg_instr_nodbg_iterator
+           I = MRI->reg_instr_nodbg_begin(LI.reg()),
+           E = MRI->reg_instr_nodbg_end();
+       I != E;) {
+    MachineInstr *MI = &*(I++);
+    if (MI->isImplicitDef())
+      continue;
+    if (!Visited.insert(MI).second)
----------------
arsenm wrote:

There are other cost double counting bugs I've been meaning to get to 

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


More information about the llvm-commits mailing list