[llvm] ba52b56 - [Analysis] Avoid repeated hash lookups (NFC) (#140691)
via llvm-commits
llvm-commits at lists.llvm.org
Tue May 20 06:47:28 PDT 2025
Author: Kazu Hirata
Date: 2025-05-20T06:47:25-07:00
New Revision: ba52b56e1864319b1044a8c6cd543be74c33b4d4
URL: https://github.com/llvm/llvm-project/commit/ba52b56e1864319b1044a8c6cd543be74c33b4d4
DIFF: https://github.com/llvm/llvm-project/commit/ba52b56e1864319b1044a8c6cd543be74c33b4d4.diff
LOG: [Analysis] Avoid repeated hash lookups (NFC) (#140691)
With this patch, we always update Inserted. That's OK because we only
read Inserted as shown in this patch. Without this patch, it's a
write-only variable.
Added:
Modified:
llvm/lib/Analysis/IRSimilarityIdentifier.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/IRSimilarityIdentifier.cpp b/llvm/lib/Analysis/IRSimilarityIdentifier.cpp
index ffb684d284a94..930b2068b3b0f 100644
--- a/llvm/lib/Analysis/IRSimilarityIdentifier.cpp
+++ b/llvm/lib/Analysis/IRSimilarityIdentifier.cpp
@@ -1306,12 +1306,11 @@ static void findCandidateStructures(
CandIt != CandEndIt; CandIt++) {
// Determine if it has an assigned structural group already.
- CandToGroupIt = CandToGroup.find(&*CandIt);
- if (CandToGroupIt == CandToGroup.end()) {
- // If not, we assign it one, and add it to our mapping.
- std::tie(CandToGroupIt, Inserted) =
- CandToGroup.insert(std::make_pair(&*CandIt, CurrentGroupNum++));
- }
+ // If not, we assign it one, and add it to our mapping.
+ std::tie(CandToGroupIt, Inserted) =
+ CandToGroup.try_emplace(&*CandIt, CurrentGroupNum);
+ if (Inserted)
+ ++CurrentGroupNum;
// Get the structural group number from the iterator.
OuterGroupNum = CandToGroupIt->second;
More information about the llvm-commits
mailing list