This is an archive of the discontinued LLVM Phabricator instance.

[BranchProbabilityInfo] Change analysis result storage to simplify basic block removal
AbandonedPublic

Authored by igor-laevsky on Jul 15 2016, 9:58 AM.

Details

Summary

This is follow up after https://reviews.llvm.org/D20957

There were concerns that in it's current form EraseBlock operation is not efficient enough. Considering that same problem was fixed for LVI (https://reviews.llvm.org/D11651) we should do the same for BranchProbabilityInfo.

This change replaces existing results cache: "(BB, SuccessorIdx) -> BranchProbability" with "BB -> (SuccessorIdx -> BranchProbability)". This allows us to efficiently perform basic block removal in a cost of slightly more expensive lookups.

Diff Detail

Event Timeline

igor-laevsky retitled this revision from to [BranchProbabilityInfo] Change analysis result storage to simplify basic block removal.
igor-laevsky updated this object.
igor-laevsky added a subscriber: llvm-commits.
dnovillo edited edge metadata.Jul 19 2016, 5:21 AM

Any changes in build time? I guess I'm surprised that removal operations are more frequent than lookups.

davidxl edited edge metadata.Jul 19 2016, 10:48 AM

Same question as Diego -- what is the build time improvement? The original version looks cleaner and easier to maintain

lib/Analysis/BranchProbabilityInfo.cpp
627

I don't quite like this EdgeProbablilityRecorded gets checked in multiple different places. It is better to isolate in one private helper function getEdgeProbability_(Src,index) that returns unknown when the index is out of range.

Hi,

I don't have specific build times. This is mostly motivated by the review comments in the https://reviews.llvm.org/D20957. Evidence for importance of this is that LVI also had linear time EraseBlock and it caused problems there. BPI will call EraseBlock exactly as frequently as LVI did, so it's natural to assume that performance bottleneck will be in the same place.

igor-laevsky abandoned this revision.Jul 22 2016, 5:18 AM