Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

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

@llvmbot
Copy link
Member

llvmbot commented Sep 29, 2024

@llvm/pr-subscribers-debuginfo

Author: Kazu Hirata (kazutakahirata)

Changes

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


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

1 Files Affected:

  • (modified) llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h (+2-6)
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;
     }
   }

Note that we must use insert_or_assign because operator[] would
require DbgValue to have the default constructor.
@kazutakahirata kazutakahirata force-pushed the cleanup_001_repeated_hash_InstrRefBasedImpl branch from 04e2340 to 5d9e1db Compare September 29, 2024 02:51
Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kazutakahirata kazutakahirata changed the title [LiveDebugValues] Avoid repeated hash lookups (NFC) [LiveDebugValues] Simplify code with MapVector::insert_or_assign (NFC) Sep 29, 2024
@kazutakahirata kazutakahirata merged commit a341820 into llvm:main Sep 29, 2024
4 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_repeated_hash_InstrRefBasedImpl branch September 29, 2024 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants