[llvm] 3a56b03 - [IR] Avoid repeated hash lookups (NFC) (#112469)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 16 06:40:17 PDT 2024
Author: Kazu Hirata
Date: 2024-10-16T06:40:10-07:00
New Revision: 3a56b03ef33a7462f8e21ed295e59b7d851f85fa
URL: https://github.com/llvm/llvm-project/commit/3a56b03ef33a7462f8e21ed295e59b7d851f85fa
DIFF: https://github.com/llvm/llvm-project/commit/3a56b03ef33a7462f8e21ed295e59b7d851f85fa.diff
LOG: [IR] Avoid repeated hash lookups (NFC) (#112469)
Added:
Modified:
llvm/lib/IR/LegacyPassManager.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/LegacyPassManager.cpp b/llvm/lib/IR/LegacyPassManager.cpp
index 96e2f1d7908ba6..ce6f6c733f4bcc 100644
--- a/llvm/lib/IR/LegacyPassManager.cpp
+++ b/llvm/lib/IR/LegacyPassManager.cpp
@@ -104,15 +104,13 @@ void PMDataManager::emitInstrCountChangedRemark(
[&FunctionToInstrCount](Function &MaybeChangedFn) {
// Update the total module count.
unsigned FnSize = MaybeChangedFn.getInstructionCount();
- auto It = FunctionToInstrCount.find(MaybeChangedFn.getName());
// If we created a new function, then we need to add it to the map and
// say that it changed from 0 instructions to FnSize.
- if (It == FunctionToInstrCount.end()) {
- FunctionToInstrCount[MaybeChangedFn.getName()] =
- std::pair<unsigned, unsigned>(0, FnSize);
+ auto [It, Inserted] = FunctionToInstrCount.try_emplace(
+ MaybeChangedFn.getName(), 0, FnSize);
+ if (Inserted)
return;
- }
// Insert the new function size into the second member of the pair. This
// tells us whether or not this function changed in size.
It->second.second = FnSize;
More information about the llvm-commits
mailing list