diff options
author | Michael Gottesman <mgottesman@apple.com> | 2013-12-14 02:24:25 +0000 |
---|---|---|
committer | Michael Gottesman <mgottesman@apple.com> | 2013-12-14 02:24:25 +0000 |
commit | fb9164f0d2f7cc51ef3952d98a367b53a53f2870 (patch) | |
tree | f0fa768e419c08833790258a9b6d236694ebc78b /llvm/lib/Analysis/BranchProbabilityInfo.cpp | |
parent | 8f17dccdcb1dbfceaaf5b14ee1186c76b0584a35 (diff) | |
download | llvm-fb9164f0d2f7cc51ef3952d98a367b53a53f2870.zip llvm-fb9164f0d2f7cc51ef3952d98a367b53a53f2870.tar.gz llvm-fb9164f0d2f7cc51ef3952d98a367b53a53f2870.tar.bz2 |
[block-freq] Teach branch probability how to return the edge weight in between a BasicBlock and one of its successors.
IMHO At some point BasicBlock should be refactored along the lines of
MachineBasicBlock so that successors/weights are actually embedded within the
block. Now is not that time though.
llvm-svn: 197303
Diffstat (limited to 'llvm/lib/Analysis/BranchProbabilityInfo.cpp')
-rw-r--r-- | llvm/lib/Analysis/BranchProbabilityInfo.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/BranchProbabilityInfo.cpp b/llvm/lib/Analysis/BranchProbabilityInfo.cpp index 86560ca..15491f0 100644 --- a/llvm/lib/Analysis/BranchProbabilityInfo.cpp +++ b/llvm/lib/Analysis/BranchProbabilityInfo.cpp @@ -11,6 +11,7 @@ // //===----------------------------------------------------------------------===// +#define DEBUG_TYPE "branch-prob" #include "llvm/Analysis/BranchProbabilityInfo.h" #include "llvm/ADT/PostOrderIterator.h" #include "llvm/Analysis/LoopInfo.h" @@ -483,6 +484,8 @@ void BranchProbabilityInfo::getAnalysisUsage(AnalysisUsage &AU) const { } bool BranchProbabilityInfo::runOnFunction(Function &F) { + DEBUG(dbgs() << "---- Branch Probability Info : " << F.getName() + << " ----\n\n"); LastF = &F; // Store the last function we ran on for printing. LI = &getAnalysis<LoopInfo>(); assert(PostDominatedByUnreachable.empty()); @@ -591,6 +594,13 @@ getEdgeWeight(const BasicBlock *Src, unsigned IndexInSuccessors) const { return DEFAULT_WEIGHT; } +uint32_t +BranchProbabilityInfo:: +getEdgeWeight(const BasicBlock *Src, succ_const_iterator Dst) const { + size_t index = std::distance(succ_begin(Src), Dst); + return getEdgeWeight(Src, index); +} + /// Get the raw edge weight calculated for the block pair. This returns the sum /// of all raw edge weights from Src to Dst. uint32_t BranchProbabilityInfo:: |