aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/Local.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2024-11-07 10:55:23 -0800
committerGitHub <noreply@github.com>2024-11-07 10:55:23 -0800
commit1ae5ecca4afb5134899d79e446afd0296d1ed5ef (patch)
tree44ec85cd000f79990999fb1adc695e82ff6c32c2 /llvm/lib/Transforms/Utils/Local.cpp
parent937e5069a740837ea3cb466df8e75a53f6d48254 (diff)
downloadllvm-1ae5ecca4afb5134899d79e446afd0296d1ed5ef.zip
llvm-1ae5ecca4afb5134899d79e446afd0296d1ed5ef.tar.gz
llvm-1ae5ecca4afb5134899d79e446afd0296d1ed5ef.tar.bz2
[Utils] Avoid repeated hash lookups (NFC) (#115262)
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index 47a7049..768765b 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.