[llvm] [IR] Avoid repeated hash lookups (NFC) (PR #128998)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 26 20:38:35 PST 2025


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/128998

None

>From dfa945c76f447bb3fb051992bdbeeb977417b08b Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Wed, 26 Feb 2025 07:44:18 -0800
Subject: [PATCH] [IR] Avoid repeated hash lookups (NFC)

---
 llvm/lib/IR/DroppedVariableStats.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/IR/DroppedVariableStats.cpp b/llvm/lib/IR/DroppedVariableStats.cpp
index d80ac9339a1b2..9e221bf585f1a 100644
--- a/llvm/lib/IR/DroppedVariableStats.cpp
+++ b/llvm/lib/IR/DroppedVariableStats.cpp
@@ -44,9 +44,10 @@ void DroppedVariableStats::calculateDroppedStatsAndPrint(
   unsigned DroppedCount = 0;
   DenseSet<VarID> &DebugVariablesBeforeSet = DbgVariables.DebugVariablesBefore;
   DenseSet<VarID> &DebugVariablesAfterSet = DbgVariables.DebugVariablesAfter;
-  if (InlinedAts.back().find(FuncName) == InlinedAts.back().end())
+  auto It = InlinedAts.back().find(FuncName);
+  if (It == InlinedAts.back().end())
     return;
-  DenseMap<VarID, DILocation *> &InlinedAtsMap = InlinedAts.back()[FuncName];
+  DenseMap<VarID, DILocation *> &InlinedAtsMap = It->second;
   // Find an Instruction that shares the same scope as the dropped #dbg_value
   // or has a scope that is the child of the scope of the #dbg_value, and has
   // an inlinedAt equal to the inlinedAt of the #dbg_value or it's inlinedAt



More information about the llvm-commits mailing list