Skip to content

[llvm-profgen] Avoid repeated hash lookups (NFC) #127028

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions llvm/tools/llvm-profgen/MissingFrameInferrer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand 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
Expand Down