forked from OSchip/llvm-project
[BOLT] Prioritize Jump Table ICP target by frequency and indice count
Summary: We select the top hot targets for indirect call promotion. But since we only have frequency for targets, not for actual jump table indices, we have to merge indices that share the same actual target. In order to do that we sort targets by pointer of target symbol before merging, which introduces instability. Later we stable sort merged targets by frequency. Due to the instability of sorting pointers, and depending on how many indices each merged target has, we could end up with unstable ICP. This commit changes the 2nd pass sorting to prioritize targets with fewer indices, and higher mispredicts, in addition to higher frequency. It improves stability of ICP, and also exposes more ICP because targets with fewer indices has better chance of getting promoted. (cherry picked from FBD16099701)
This commit is contained in:
parent
078ece1691
commit
4e90fc1e3b
|
@ -341,10 +341,17 @@ IndirectCallPromotion::getCallTargets(
|
|||
}
|
||||
}
|
||||
|
||||
// Sort by most commonly called targets.
|
||||
// Sort by target count, number of indices in case of jump table, and
|
||||
// mispredicts. We prioritize targets with high count, small number of
|
||||
// indices and high mispredicts
|
||||
std::stable_sort(Targets.begin(), Targets.end(),
|
||||
[](const Callsite &A, const Callsite &B) {
|
||||
return A.Branches > B.Branches;
|
||||
if (A.Branches != B.Branches)
|
||||
return A.Branches > B.Branches;
|
||||
else if (A.JTIndices.size() != B.JTIndices.size())
|
||||
return A.JTIndices.size() < B.JTIndices.size();
|
||||
else
|
||||
return A.Mispreds > B.Mispreds;
|
||||
});
|
||||
|
||||
// Remove non-symbol targets
|
||||
|
|
Loading…
Reference in New Issue