[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:10 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())
----------------
arsenm wrote:

```suggestion
    if (MI->isMetaInstruction())
```

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


More information about the llvm-commits mailing list