[llvm] [RegAllocFast] Give an undef tied use the register of its tied def (PR #222249)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 9 01:52:09 PDT 2026
================
@@ -1031,6 +1031,28 @@ void RegAllocFastImpl::allocVirtRegUndef(MachineOperand &MO) {
if (!shouldAllocateRegister(VirtReg))
return;
+ // The def is freed before the uses are allocated, so a tie is the only
+ // record left of its register. Rewrite every read of VirtReg so they agree.
+ MachineInstr &MI = *MO.getParent();
+ for (const MachineOperand &Tied : MI.all_uses()) {
+ if (!Tied.isTied() || Tied.getReg() != VirtReg)
+ continue;
+ unsigned TiedIdx = MI.findTiedOperandIdx(MI.getOperandNo(&Tied));
+ MCRegister DefReg = MI.getOperand(TiedIdx).getReg().asMCReg();
----------------
MaskRay wrote:
Phase ordering. See the comment below `RegAllocFastImpl::allocateInstruction`. Uses are handled after defs. Every virtual def the pass allocates is already rewritten at this step.
https://github.com/llvm/llvm-project/pull/222249
More information about the llvm-commits
mailing list