[llvm] 1ae5ecc - [Utils] Avoid repeated hash lookups (NFC) (#115262)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 7 10:55:26 PST 2024
Author: Kazu Hirata
Date: 2024-11-07T10:55:23-08:00
New Revision: 1ae5ecca4afb5134899d79e446afd0296d1ed5ef
URL: https://github.com/llvm/llvm-project/commit/1ae5ecca4afb5134899d79e446afd0296d1ed5ef
DIFF: https://github.com/llvm/llvm-project/commit/1ae5ecca4afb5134899d79e446afd0296d1ed5ef.diff
LOG: [Utils] Avoid repeated hash lookups (NFC) (#115262)
Added:
Modified:
llvm/lib/Transforms/Utils/Local.cpp
Removed:
################################################################################
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.
More information about the llvm-commits
mailing list