[llvm] [LiveDebugValues] Avoid repeated hash lookups (NFC) (PR #110398)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 28 19:03:01 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/110398
Note that we must use insert_or_assign because operator[] would
require DbgValue to have the default constructor.
>From 04e23404df88a8f688d8b49ff2fb016b46b47984 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 28 Sep 2024 13:19:41 -0700
Subject: [PATCH] [LiveDebugValues] Avoid repeated hash lookups (NFC)
Note that we must use insert_or_assign because operator[] would
require DbgValue to have the default constructor.
---
llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
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