[llvm] [InlineSpiller] Avoid spill hoisting interference (PR #211809)
Lukas Sommer via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 24 07:39:57 PDT 2026
================
@@ -454,6 +454,34 @@ bool InlineSpiller::hoistSpillInsideBB(LiveInterval &SpillLI,
if (DefMBB != CopyMI.getParent() || !SrcQ.isKill())
return false;
+ MachineBasicBlock *MBB = DefMBB;
+ MachineBasicBlock::iterator MII;
+ if (SrcVNI->isPHIDef())
+ MII = MBB->SkipPHIsLabelsAndDebug(MBB->begin(), SrcReg);
+ else {
+ MachineInstr *DefMI = LIS.getInstructionFromIndex(SrcVNI->def);
+ assert(DefMI && "Defining instruction disappeared");
+ MII = DefMI;
+ ++MII;
+ }
+
----------------
sommerlukas wrote:
There could be an argument made that we shouldn't perform the hoisting if the insertion point (`MII`) is after the copy (`CopyMI`) or after the end of the current segment of the source's live interval, because:
- We're not hoisting as promised by the function name, but actually sinking.
- We're increasing register pressure, as the source's live interval is potentially extended.
However, I've decided to go with this more targeted fix for now to preserve existing behavior and only avoid the hoisting in cases that would lead to interference.
https://github.com/llvm/llvm-project/pull/211809
More information about the llvm-commits
mailing list