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

via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 26 20:39:07 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-ir

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/128998.diff


1 Files Affected:

- (modified) llvm/lib/IR/DroppedVariableStats.cpp (+3-2) 


``````````diff
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

``````````

</details>


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


More information about the llvm-commits mailing list