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

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


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-regalloc

Author: Matt Arsenault (arsenm)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/120046.diff


1 Files Affected:

- (modified) llvm/lib/CodeGen/RegAllocBase.cpp (+4-6) 


``````````diff
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()));
     }
   }
 

``````````

</details>


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


More information about the llvm-commits mailing list