[llvm] 5fa989b - [Analysis] Avoid repeated hash lookups (NFC) (#123159)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 16 08:45:30 PST 2025
Author: Kazu Hirata
Date: 2025-01-16T08:45:27-08:00
New Revision: 5fa989b034236ebf5a808dd47af50ab29d991a7d
URL: https://github.com/llvm/llvm-project/commit/5fa989b034236ebf5a808dd47af50ab29d991a7d
DIFF: https://github.com/llvm/llvm-project/commit/5fa989b034236ebf5a808dd47af50ab29d991a7d.diff
LOG: [Analysis] Avoid repeated hash lookups (NFC) (#123159)
Added:
Modified:
llvm/lib/Analysis/InstructionPrecedenceTracking.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/InstructionPrecedenceTracking.cpp b/llvm/lib/Analysis/InstructionPrecedenceTracking.cpp
index fba5859b74cef3..9555e2c8dd5dd7 100644
--- a/llvm/lib/Analysis/InstructionPrecedenceTracking.cpp
+++ b/llvm/lib/Analysis/InstructionPrecedenceTracking.cpp
@@ -115,8 +115,9 @@ void InstructionPrecedenceTracking::insertInstructionTo(const Instruction *Inst,
void InstructionPrecedenceTracking::removeInstruction(const Instruction *Inst) {
auto *BB = Inst->getParent();
assert(BB && "must be called before instruction is actually removed");
- if (FirstSpecialInsts.count(BB) && FirstSpecialInsts[BB] == Inst)
- FirstSpecialInsts.erase(BB);
+ auto It = FirstSpecialInsts.find(BB);
+ if (It != FirstSpecialInsts.end() && It->second == Inst)
+ FirstSpecialInsts.erase(It);
}
void InstructionPrecedenceTracking::removeUsersOf(const Instruction *Inst) {
More information about the llvm-commits
mailing list