llvm-project
9af2dcea - LiveIntervals: fix shrinkToUses to consider early-clobber slots (#238749)

Commit
11 hours ago
LiveIntervals: fix shrinkToUses to consider early-clobber slots (#238749) shrinkSubRangeToUses() is called by PHIElimination, before TwoAddressInstruction ensures tied operands share the same vreg. It tries to find early-clobber uses by checking if the used vreg is also defined by the parent instruction. This cannot happen, as tied uses haven't been rewritten yet. Instead, we need to query whether the use is tied to an early clobber def when still in SSA form. This is similar to what LiveIntervalCalc does when building a LiveInterval. A common MachineOperand::isEarlyClobberDefOrUse() has been created. Note that PHIElimination does not call shrinkToUses for the main range, and instead shrinks the LI itself. It preserves the original slot that was found by LiveIntervalCalc, so no fix was needed there. I still updated shrinkToUses to use isEarlyClobberDefOrUse. This ensures the later TwoAddressInstruction does not temporarily create wrong intervals when rewriting tied registers. TLDR: The main range and sub-ranges now correctly preserve early-clobber slots. This ensures that the main range still covers all sub-ranges after PHIElimination. I found this issue while enabling subreg liveness tracking for AArch64. Assisted-by: codex (test reduction)
Author
Parents
Loading