[llvm] [CodeGen] Use insert idiom in CFIInstrInserter instead of find [nfc] (PR #170760)

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 4 14:13:48 PST 2025


https://github.com/preames created https://github.com/llvm/llvm-project/pull/170760

None

>From 55b548d0d8595db8b9864ca31765f274cf8cd51d Mon Sep 17 00:00:00 2001
From: Philip Reames <preames at rivosinc.com>
Date: Thu, 4 Dec 2025 14:12:31 -0800
Subject: [PATCH] [CodeGen] Use insert idiom in CFIInstrInserter instead of
 find [nfc]

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

diff --git a/llvm/lib/CodeGen/CFIInstrInserter.cpp b/llvm/lib/CodeGen/CFIInstrInserter.cpp
index 54b93a627938f..38858270c9197 100644
--- a/llvm/lib/CodeGen/CFIInstrInserter.cpp
+++ b/llvm/lib/CodeGen/CFIInstrInserter.cpp
@@ -279,10 +279,8 @@ void CFIInstrInserter::calculateOutgoingCFAInfo(MBBCFAInfo &MBBInfo) {
       }
       if (CSRReg || CSROffset) {
         CSRSavedLocation Loc(CSRReg, CSROffset);
-        auto It = CSRLocMap.find(CFI.getRegister());
-        if (It == CSRLocMap.end()) {
-          CSRLocMap.insert({CFI.getRegister(), Loc});
-        } else if (It->second != Loc) {
+        auto [It, Inserted] = CSRLocMap.insert({CFI.getRegister(), Loc});
+        if (!Inserted && It->second != Loc) {
           reportFatalInternalError(
               "Different saved locations for the same CSR");
         }



More information about the llvm-commits mailing list