[llvm] RegAlloc: Use DiagnosticInfo to report register allocation failures (PR #119492)

Quentin Colombet via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 11 04:58:06 PST 2024


================
@@ -963,14 +963,22 @@ void RegAllocFastImpl::allocVirtReg(MachineInstr &MI, LiveReg &LR,
   if (!BestReg) {
     // Nothing we can do: Report an error and keep going with an invalid
     // allocation.
-    if (MI.isInlineAsm())
+    if (MI.isInlineAsm()) {
       MI.emitInlineAsmError(
           "inline assembly requires more registers than available");
-    else
-      MI.emitInlineAsmError("ran out of registers during register allocation");
+    } else {
+      const Function &Fn = MBB->getParent()->getFunction();
+      DiagnosticInfoRegAllocFailure DI(
+          "ran out of registers during register allocation", Fn,
+          MI.getDebugLoc());
+      Fn.getContext().diagnose(DI);
+    }
 
     LR.Error = true;
-    LR.PhysReg = 0;
+    if (!AllocationOrder.empty())
+      LR.PhysReg = AllocationOrder.front();
----------------
qcolombet wrote:

LR.PhysReg = 0 makes more sense to me (the original code).
Why are you still trying to assign something at this point?

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


More information about the llvm-commits mailing list