[llvm] [Analysis] Avoid repeated hash lookups (NFC) (PR #123159)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 15 20:50:48 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-analysis
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/123159.diff
1 Files Affected:
- (modified) llvm/lib/Analysis/InstructionPrecedenceTracking.cpp (+3-2)
``````````diff
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) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/123159
More information about the llvm-commits
mailing list