[llvm] [llvm-dwarfdump] Avoid repeated hash lookups (NFC) (PR #129991)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 5 21:57:44 PST 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/129991
None
>From b1c112d434e4191a069d68db86cc51f19a523c7c Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Wed, 5 Mar 2025 09:02:28 -0800
Subject: [PATCH] [llvm-dwarfdump] Avoid repeated hash lookups (NFC)
---
llvm/tools/llvm-dwarfdump/Statistics.cpp | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/llvm/tools/llvm-dwarfdump/Statistics.cpp b/llvm/tools/llvm-dwarfdump/Statistics.cpp
index 1670709c08314..af9a93ad35b9c 100644
--- a/llvm/tools/llvm-dwarfdump/Statistics.cpp
+++ b/llvm/tools/llvm-dwarfdump/Statistics.cpp
@@ -529,8 +529,9 @@ static void collectStatsRecursive(
auto OffsetFn = Die.find(dwarf::DW_AT_abstract_origin);
if (OffsetFn) {
uint64_t OffsetOfInlineFnCopy = (*OffsetFn).getRawUValue();
- if (LocalAbstractOriginFnInfo.count(OffsetOfInlineFnCopy)) {
- AbstractOriginVars = LocalAbstractOriginFnInfo[OffsetOfInlineFnCopy];
+ if (auto It = LocalAbstractOriginFnInfo.find(OffsetOfInlineFnCopy);
+ It != LocalAbstractOriginFnInfo.end()) {
+ AbstractOriginVars = It->second;
AbstractOriginVarsPtr = &AbstractOriginVars;
} else {
// This means that the DW_AT_inline fn copy is out of order
@@ -782,9 +783,10 @@ static void collectZeroLocCovForVarsWithAbstractOrigin(
// If there is no entry within LocalAbstractOriginFnInfo for the given
// FnCopyRawUValue, function isn't out-of-order in DWARF. Rather, we have
// CrossCU referencing.
- if (!LocalAbstractOriginFnInfo.count(FnCopyRawUValue))
+ auto It = LocalAbstractOriginFnInfo.find(FnCopyRawUValue);
+ if (It == LocalAbstractOriginFnInfo.end())
continue;
- AbstractOriginVars = LocalAbstractOriginFnInfo[FnCopyRawUValue];
+ AbstractOriginVars = It->second;
updateVarsWithAbstractOriginLocCovInfo(FnDieWithAbstractOrigin,
AbstractOriginVars);
More information about the llvm-commits
mailing list