From 544c145007130b7337e7405ff0dc9d058bb016ca Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Wed, 12 Feb 2025 09:09:11 -0800 Subject: [PATCH] [llvm-profgen] Avoid repeated hash lookups (NFC) --- llvm/tools/llvm-profgen/MissingFrameInferrer.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/llvm/tools/llvm-profgen/MissingFrameInferrer.cpp b/llvm/tools/llvm-profgen/MissingFrameInferrer.cpp index eefe38cd3fa00..ac88fced9159c 100644 --- a/llvm/tools/llvm-profgen/MissingFrameInferrer.cpp +++ b/llvm/tools/llvm-profgen/MissingFrameInferrer.cpp @@ -238,12 +238,13 @@ bool MissingFrameInferrer::inferMissingFrames( return false; // Bail out if caller has no known outgoing call edges. - if (!CallEdgesF.count(From)) + auto It = CallEdgesF.find(From); + if (It == CallEdgesF.end()) return false; // Done with the inference if the calle is reachable via a single callsite. // This may not be accurate but it improves the search throughput. - if (llvm::is_contained(CallEdgesF[From], ToFRange->Func)) + if (llvm::is_contained(It->second, ToFRange->Func)) return true; // Bail out if callee is not tailcall reachable at all. @@ -253,7 +254,7 @@ bool MissingFrameInferrer::inferMissingFrames( Visiting.clear(); CurSearchingDepth = 0; uint64_t NumPaths = 0; - for (auto Target : CallEdgesF[From]) { + for (auto Target : It->second) { NumPaths += computeUniqueTailCallPath(Target, ToFRange->Func, UniquePath); // Stop analyzing the remaining if we are already seeing more than one