This is an archive of the discontinued LLVM Phabricator instance.

[BPI] Compile time improvement when erasing blocks (NFC)
ClosedPublic

Authored by tejohnson on Jul 10 2020, 4:25 PM.

Details

Summary

eraseBlock is trying to erase all probability info for the given BB.
This info is stored in a DenseMap organized like so:

using Edge = std::pair<const BasicBlock *, unsigned>;
DenseMap<Edge, BranchProbability> Probs;

where the unsigned in the Edge key is the successor id.

It was walking through every single map entry, checking if the BB in the
key's pair matched the given BB. Much more efficient is to do what
another method (getEdgeProbability) was already doing, which is to walk
the successors of the BB, and simply do a map lookup on the key formed
from each <BB, successor id> pair.

Doing this dropped the overall compile time for a file containing a
very large function by around 32%.

Diff Detail

Event Timeline

tejohnson created this revision.Jul 10 2020, 4:25 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 10 2020, 4:25 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
davidxl accepted this revision.Jul 10 2020, 4:50 PM

lgtm

This revision is now accepted and ready to land.Jul 10 2020, 4:50 PM
This revision was automatically updated to reflect the committed changes.