This is an archive of the discontinued LLVM Phabricator instance.

[BOLT] Do not merge cold and hot chains of basic blocks
ClosedPublic

Authored by spupyrev on Jul 8 2022, 1:34 PM.

Details

Summary

There is a post-processing in ext-tsp block reordering that merges some blocks
into chains. This allows to maintain the original block order in the absense of
profile data and can be beneficial for code size (when fallthroughs are merged).
In the earlier version we could merge hot and cold (with zero execution count)
chains, that later were split by SplitFunction.cpp (when split-all-cold=1). The
diff eliminates the redundant merging.

It is unlikely the change will affect the performance of a binary in a
measurable way, as it is mostly operates with cold basic blocks. However, after
the diff the impact of split-all-cold is almost negligible and we can avoid the
extra function splitting.

Measuring on the clang binary (negative is good, positive is a regression):
clang12
benchmark1: 0.0253
benchmark2: -0.1843
benchmark3: 0.3234
benchmark4: 0.0333

clang10
benchmark1 -0.2517
benchmark2 -0.3703
benchmark3 -0.1186
benchmark4 -0.3822

clang7
benchmark1 0.2526
benchmark2 0.0500
benchmark3 0.3024
benchmark4 -0.0489

Overall: -0.0671 ± 0.1172 (insignificant)

Diff Detail

Event Timeline

spupyrev created this revision.Jul 8 2022, 1:34 PM
Herald added a reviewer: Amir. · View Herald Transcript
Herald added a reviewer: maksfb. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: ayermolo. · View Herald Transcript
spupyrev requested review of this revision.Jul 8 2022, 1:34 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 8 2022, 1:34 PM
spupyrev retitled this revision from Do not merge cold with hot chains to [BOLT] Do not merge cold and hot chains of basic blocks.Jul 8 2022, 1:46 PM
spupyrev edited the summary of this revision. (Show Details)
maksfb accepted this revision.Jul 8 2022, 3:02 PM

LGTM

This revision is now accepted and ready to land.Jul 8 2022, 3:02 PM
spupyrev updated this revision to Diff 443625.Jul 11 2022, 6:55 AM
spupyrev edited the summary of this revision. (Show Details)

rebase

This revision was automatically updated to reflect the committed changes.