[all-commits] [llvm/llvm-project] 2f1038: [BranchProbabilityInfo] Use SmallVector (NFC)

kazutakahirata via All-commits all-commits at lists.llvm.org
Mon Nov 9 17:30:23 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 2f1038c7b699e959e0521638e2e2818a849fe19c
      https://github.com/llvm/llvm-project/commit/2f1038c7b699e959e0521638e2e2818a849fe19c
  Author: Kazu Hirata <kazu at google.com>
  Date:   2020-11-09 (Mon, 09 Nov 2020)

  Changed paths:
    M llvm/include/llvm/Analysis/BranchProbabilityInfo.h
    M llvm/lib/Analysis/BranchProbabilityInfo.cpp

  Log Message:
  -----------
  [BranchProbabilityInfo] Use SmallVector (NFC)

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);

Differential Revision: https://reviews.llvm.org/D91017




More information about the All-commits mailing list