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

via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 4 16:52:18 PST 2025


Author: Philip Reames
Date: 2025-12-04T16:52:14-08:00
New Revision: da06d9eeafe29af089fb16ad2af5731205f7e56c

URL: https://github.com/llvm/llvm-project/commit/da06d9eeafe29af089fb16ad2af5731205f7e56c
DIFF: https://github.com/llvm/llvm-project/commit/da06d9eeafe29af089fb16ad2af5731205f7e56c.diff

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

Added: 
    

Modified: 
    llvm/lib/CodeGen/CFIInstrInserter.cpp

Removed: 
    


################################################################################
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