[llvm] df09290 - [Analysis] Avoid repeated hash lookups (NFC) (#126851)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 12 08:45:31 PST 2025
Author: Kazu Hirata
Date: 2025-02-12T08:45:27-08:00
New Revision: df092904075e9a9de3c8f9dd4f2da5efc94d4712
URL: https://github.com/llvm/llvm-project/commit/df092904075e9a9de3c8f9dd4f2da5efc94d4712
DIFF: https://github.com/llvm/llvm-project/commit/df092904075e9a9de3c8f9dd4f2da5efc94d4712.diff
LOG: [Analysis] Avoid repeated hash lookups (NFC) (#126851)
Added:
Modified:
llvm/include/llvm/Analysis/SparsePropagation.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/SparsePropagation.h b/llvm/include/llvm/Analysis/SparsePropagation.h
index cc79870229873..b85e11942a320 100644
--- a/llvm/include/llvm/Analysis/SparsePropagation.h
+++ b/llvm/include/llvm/Analysis/SparsePropagation.h
@@ -244,13 +244,13 @@ SparseSolver<LatticeKey, LatticeVal, KeyInfo>::getValueState(LatticeKey Key) {
template <class LatticeKey, class LatticeVal, class KeyInfo>
void SparseSolver<LatticeKey, LatticeVal, KeyInfo>::UpdateState(LatticeKey Key,
LatticeVal LV) {
- auto I = ValueState.find(Key);
- if (I != ValueState.end() && I->second == LV)
+ auto [I, Inserted] = ValueState.try_emplace(Key);
+ if (!Inserted && I->second == LV)
return; // No change.
// Update the state of the given LatticeKey and add its corresponding LLVM
// value to the work list.
- ValueState[Key] = std::move(LV);
+ I->second = std::move(LV);
if (Value *V = KeyInfo::getValueFromLatticeKey(Key))
ValueWorkList.push_back(V);
}
More information about the llvm-commits
mailing list