This is an archive of the discontinued LLVM Phabricator instance.

Use unique_ptr in BlockFrequencyAnalysis
AbandonedPublic

Authored by eraman on Mar 4 2016, 5:37 PM.

Details

Reviewers
dblaikie

Diff Detail

Event Timeline

eraman updated this revision to Diff 49865.Mar 4 2016, 5:37 PM
eraman retitled this revision from to Use unique_ptr in BlockFrequencyAnalysis.
eraman updated this object.
eraman added a reviewer: dblaikie.
eraman added a subscriber: llvm-commits.
dblaikie edited edge metadata.Mar 7 2016, 6:54 AM

Generally looks good. A couple of optional comments (feel free to commit with or without those changes, without further review)

lib/Analysis/InlineCost.cpp
1580

Use "= default" perhaps? (no big reason, if you particularly prefer "{}", that's OK)

1585–1595

This function does an extra map lookup (2, could use 1 - assuming that the code to build the BFI doesn't cause other BFIs to be constructed (invalidating access to the entry in the map))

& I'd consider rewriting it as something like:

auto &BFI = BFM[F]
if (!BFI) {
  DominatorTree DT;
  DT.recalculate(*F);
  LoopInfo LI(DT);
  BranchProbabilityInfo BPI(*F, LI);
  BFI = llvm::make_unique<BlockFrequencyInfo>(*F, BPI, LI);
}
return BFI.get();
dblaikie accepted this revision.Mar 7 2016, 6:54 AM
dblaikie edited edge metadata.
This revision is now accepted and ready to land.Mar 7 2016, 6:54 AM
eraman abandoned this revision.Mar 9 2016, 11:43 AM