[llvm] [Utils] Avoid repeated hash lookups (NFC) (PR #115262)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 6 20:23:12 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/115262.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Utils/Local.cpp (+3-5)
``````````diff
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index 47a70492559610..768765b6c1e632 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -2178,11 +2178,9 @@ void llvm::insertDebugValuesForPHIs(BasicBlock *BB,
auto V = DbgValueMap.find(VI);
if (V != DbgValueMap.end()) {
auto *DbgII = cast<DbgVariableIntrinsic>(V->second);
- auto NewDI = NewDbgValueMap.find({Parent, DbgII});
- if (NewDI == NewDbgValueMap.end()) {
- auto *NewDbgII = cast<DbgVariableIntrinsic>(DbgII->clone());
- NewDI = NewDbgValueMap.insert({{Parent, DbgII}, NewDbgII}).first;
- }
+ auto [NewDI, Inserted] = NewDbgValueMap.try_emplace({Parent, DbgII});
+ if (Inserted)
+ NewDI->second = cast<DbgVariableIntrinsic>(DbgII->clone());
DbgVariableIntrinsic *NewDbgII = NewDI->second;
// If PHI contains VI as an operand more than once, we may
// replaced it in NewDbgII; confirm that it is present.
``````````
</details>
https://github.com/llvm/llvm-project/pull/115262
More information about the llvm-commits
mailing list