[PATCH] D91017: [BranchProbabilityInfo] Use SmallVector (NFC)

Kazu Hirata via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 7 15:11:16 PST 2020


kazu created this revision.
kazu added reviewers: MaskRay, yrouban.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
kazu requested review of this revision.

This patch simplifies BranchProbabilityInfo by changing the type of
Probs.

Without this patch:

  DenseMap<Edge, BranchProbability> Probs

maps an ordered pair of a BasicBlock* and a successor index to an edge
probability.

With this patch:

  DenseMap<const BasicBlock *, SmallVector<BranchProbability, 2>> Probs

maps a BasicBlock* to a vector of edge probabilities.

BranchProbabilityInfo has a property that for a given basic block, we
either have edge probabilities for all successors or do not have any
edge probability at all.  This property combined with the current map
type leads to a somewhat complicated algorithm in eraseBlock to erase
map entries one by one while increasing the successor index.

The new map type allows us to remove the all edge probabilities for a
given basic block in a more intuitive manner, namely:

  Probs.erase(BB);


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91017

Files:
  llvm/include/llvm/Analysis/BranchProbabilityInfo.h
  llvm/lib/Analysis/BranchProbabilityInfo.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91017.303678.patch
Type: text/x-patch
Size: 5183 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201107/93e1754c/attachment.bin>


More information about the llvm-commits mailing list