[llvm] RegAllocFast: Fix verifier errors after assigning to reserved registers (PR #128155)

Carl Ritson via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 21 02:32:17 PST 2025


================
@@ -1215,16 +1218,30 @@ MCPhysReg RegAllocFastImpl::getErrorAssignment(const LiveReg &LR,
 /// Changes operand OpNum in MI the refer the PhysReg, considering subregs.
 /// \return true if MI's MachineOperands were re-arranged/invalidated.
 bool RegAllocFastImpl::setPhysReg(MachineInstr &MI, MachineOperand &MO,
-                                  MCPhysReg PhysReg) {
+                                  const LiveReg &Assignment) {
+  MCPhysReg PhysReg = Assignment.PhysReg;
+
+  assert(PhysReg);
+
+  if (LLVM_UNLIKELY(Assignment.Error)) {
+    if (MO.isUse())
+      MO.setIsUndef(true);
+  }
+
   if (!MO.getSubReg()) {
     MO.setReg(PhysReg);
-    MO.setIsRenamable(true);
+    MO.setIsRenamable(!Assignment.Error);
     return false;
   }
 
+  assert(PhysReg);
----------------
perlfu wrote:

As above.

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


More information about the llvm-commits mailing list