Skip to content

Commit

Permalink
[BOLT] Fix ICPJumpTablesTopN option use
Browse files Browse the repository at this point in the history
Fix non-sensical `opts::ICPJumpTablesTopN != 0 ? opts::ICPTopN : opts::ICPTopN`.
Refactor/simplify another similar assignment.

Reviewed By: rafauler

Differential Revision: https://reviews.llvm.org/D124880
  • Loading branch information
aaupov committed May 4, 2022
1 parent c3d5372 commit 60957a5
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions bolt/lib/Passes/IndirectCallPromotion.cpp
Expand Up @@ -546,7 +546,7 @@ IndirectCallPromotion::findCallTargetSymbols(std::vector<Callsite> &Targets,
}
uint64_t RemainingMemAccesses = TotalMemAccesses;
const size_t TopN =
opts::ICPJumpTablesTopN != 0 ? opts::ICPTopN : opts::ICPTopN;
opts::ICPJumpTablesTopN ? opts::ICPJumpTablesTopN : opts::ICPTopN;
size_t I = 0;
for (; I < HotTargets.size(); ++I) {
const uint64_t MemAccesses = HotTargets[I].first;
Expand Down Expand Up @@ -942,12 +942,11 @@ size_t IndirectCallPromotion::canPromoteCallsite(
}

size_t TopN = opts::ICPTopN;
if (IsJumpTable) {
if (opts::ICPJumpTablesTopN != 0)
TopN = opts::ICPJumpTablesTopN;
} else if (opts::ICPCallsTopN != 0) {
TopN = opts::ICPCallsTopN;
}
if (IsJumpTable)
TopN = opts::ICPJumpTablesTopN ? opts::ICPJumpTablesTopN : TopN;
else
TopN = opts::ICPCallsTopN ? opts::ICPCallsTopN : TopN;

const size_t TrialN = TopN ? std::min(TopN, Targets.size()) : Targets.size();

if (opts::ICPTopCallsites > 0) {
Expand Down

0 comments on commit 60957a5

Please sign in to comment.