[llvm] RegAllocBase: Avoid using temporary DiagnosticInfo (PR #120046)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 15 23:18:44 PST 2024


https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/120046

None

>From 2006284d690790b0f43a2ff48a9e291b465853c2 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Mon, 16 Dec 2024 14:14:05 +0700
Subject: [PATCH] RegAllocBase: Avoid using temporary DiagnosticInfo

---
 llvm/lib/CodeGen/RegAllocBase.cpp | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/llvm/lib/CodeGen/RegAllocBase.cpp b/llvm/lib/CodeGen/RegAllocBase.cpp
index 980a6756963d9f..50addcbcca065a 100644
--- a/llvm/lib/CodeGen/RegAllocBase.cpp
+++ b/llvm/lib/CodeGen/RegAllocBase.cpp
@@ -200,10 +200,9 @@ MCPhysReg RegAllocBase::getErrorAssignment(const TargetRegisterClass &RC,
     ArrayRef<MCPhysReg> RawRegs = RC.getRegisters();
 
     if (EmitError) {
-      DiagnosticInfoRegAllocFailure DI(
+      Context.diagnose(DiagnosticInfoRegAllocFailure(
           "no registers from class available to allocate", Fn,
-          CtxMI ? CtxMI->getDebugLoc() : DiagnosticLocation());
-      Context.diagnose(DI);
+          CtxMI ? CtxMI->getDebugLoc() : DiagnosticLocation()));
     }
 
     assert(!RawRegs.empty() && "register classes cannot have no registers");
@@ -215,10 +214,9 @@ MCPhysReg RegAllocBase::getErrorAssignment(const TargetRegisterClass &RC,
       CtxMI->emitInlineAsmError(
           "inline assembly requires more registers than available");
     } else {
-      DiagnosticInfoRegAllocFailure DI(
+      Context.diagnose(DiagnosticInfoRegAllocFailure(
           "ran out of registers during register allocation", Fn,
-          CtxMI ? CtxMI->getDebugLoc() : DiagnosticLocation());
-      Context.diagnose(DI);
+          CtxMI ? CtxMI->getDebugLoc() : DiagnosticLocation()));
     }
   }
 



More information about the llvm-commits mailing list