This is an archive of the discontinued LLVM Phabricator instance.

[BPI] Refactor post domination calculation and simple fix for ColdCall
ClosedPublic

Authored by skatkov on Apr 5 2017, 1:59 AM.

Details

Summary

Collection of PostDominatedByUnreachable and PostDominatedByColdCall have been split
out of heuristics itself. Update of the data happens now for each basic block (before update
for PostDominatedByColdCall might be skipped if unreachable or matadata heuristic
handled this basic block).

This separation allows re-ordering of heuristics without loosing the post-domination information.

Diff Detail

Repository
rL LLVM

Event Timeline

skatkov created this revision.Apr 5 2017, 1:59 AM
chandlerc added inline comments.Apr 5 2017, 9:33 PM
lib/Analysis/BranchProbabilityInfo.cpp
150–156 ↗(On Diff #94175)

You can rewrite this without the loop:

if (llvm::all_of(successors(BB), [&](BasicBlock *SuccBB) {
      return PostDominatedByColdCall.count(SuccBB);
    })) {
  PostDominatedByColdCall.insert(BB);
  return;
}
161–166 ↗(On Diff #94175)

Use a range based for loop over the instructions, and directly insert and return here?

170–174 ↗(On Diff #94175)

Do this first (before walking successors)? Then you can just insert and return rather than needing a bool.

skatkov updated this revision to Diff 94629.Apr 9 2017, 9:37 PM

The original idea was to separate the checks and action. However I'm ok with that as well.

skatkov marked 3 inline comments as done.Apr 9 2017, 9:38 PM
chandlerc accepted this revision.Apr 10 2017, 2:27 PM

LGTM as well.

This revision is now accepted and ready to land.Apr 10 2017, 2:27 PM
This revision was automatically updated to reflect the committed changes.