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

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 11 15:08:47 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();
----------------
arsenm wrote:

LR.PhysReg is used as a lack of assignment marker in non-error situations. We need a definitive registers assignment. This will get cleaned up more in a pending PR 

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


More information about the llvm-commits mailing list