[llvm] a341820 - [LiveDebugValues] Simplify code with MapVector::insert_or_assign (NFC) (#110398)

via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 29 08:54:08 PDT 2024


Author: Kazu Hirata
Date: 2024-09-29T08:54:06-07:00
New Revision: a341820fef75e23af698e0a80c0177a72d8f0a00

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

LOG: [LiveDebugValues] Simplify code with MapVector::insert_or_assign (NFC) (#110398)

Note that we must use insert_or_assign because operator[] would
require DbgValue to have the default constructor.

Added: 
    

Modified: 
    llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h
index 5c095e79599f6a..f157ffc6bcc2d7 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h
+++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h
@@ -1070,9 +1070,7 @@ class VLocTracker {
                        : DbgValue(Properties, DbgValue::Undef);
 
     // Attempt insertion; overwrite if it's already mapped.
-    auto Result = Vars.insert(std::make_pair(VarID, Rec));
-    if (!Result.second)
-      Result.first->second = Rec;
+    Vars.insert_or_assign(VarID, Rec);
     Scopes[VarID] = MI.getDebugLoc().get();
 
     considerOverlaps(Var, MI.getDebugLoc().get());
@@ -1100,9 +1098,7 @@ class VLocTracker {
       DbgValue Rec = DbgValue(EmptyProperties, DbgValue::Undef);
 
       // Attempt insertion; overwrite if it's already mapped.
-      auto Result = Vars.insert(std::make_pair(OverlappedID, Rec));
-      if (!Result.second)
-        Result.first->second = Rec;
+      Vars.insert_or_assign(OverlappedID, Rec);
       Scopes[OverlappedID] = Loc;
     }
   }


        


More information about the llvm-commits mailing list