summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2011-10-24 01:40:45 +0000
committerChandler Carruth <chandlerc@gmail.com>2011-10-24 01:40:45 +0000
commitb068bbbaecf338f481124551a5e6f37484fad800 (patch)
treec38e7fba6fda4cc4c7dd1251c79741c5809be2e0 /include
parent795cb48f1a1f01ce55b32d3d3caca728a4122d7d (diff)
downloadllvm-b068bbbaecf338f481124551a5e6f37484fad800.tar.gz
llvm-b068bbbaecf338f481124551a5e6f37484fad800.tar.bz2
llvm-b068bbbaecf338f481124551a5e6f37484fad800.tar.xz
Simplify the design of BranchProbabilityInfo by collapsing it into
a single class. Previously it was split between two classes, one internal and one external. The concern seemed to center around exposing the weights used, but those can remain confined to the implementation file. Having a single class to maintain the state and analyses in use will also simplify several of the enhancements I want to make to our static heuristics. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142783 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Analysis/BranchProbabilityInfo.h50
1 files changed, 30 insertions, 20 deletions
diff --git a/include/llvm/Analysis/BranchProbabilityInfo.h b/include/llvm/Analysis/BranchProbabilityInfo.h
index 180d230b4c..82360dcfbf 100644
--- a/include/llvm/Analysis/BranchProbabilityInfo.h
+++ b/include/llvm/Analysis/BranchProbabilityInfo.h
@@ -20,29 +20,10 @@
#include "llvm/Support/BranchProbability.h"
namespace llvm {
-
+class LoopInfo;
class raw_ostream;
class BranchProbabilityInfo : public FunctionPass {
-
- // Default weight value. Used when we don't have information about the edge.
- // TODO: DEFAULT_WEIGHT makes sense during static predication, when none of
- // the successors have a weight yet. But it doesn't make sense when providing
- // weight to an edge that may have siblings with non-zero weights. This can
- // be handled various ways, but it's probably fine for an edge with unknown
- // weight to just "inherit" the non-zero weight of an adjacent successor.
- static const uint32_t DEFAULT_WEIGHT = 16;
-
- typedef std::pair<const BasicBlock *, const BasicBlock *> Edge;
-
- DenseMap<Edge, uint32_t> Weights;
-
- /// \brief Track the last function we run over for printing.
- Function *LastF;
-
- // Get sum of the block successors' weights.
- uint32_t getSumForBlock(const BasicBlock *BB) const;
-
public:
static char ID;
@@ -79,6 +60,35 @@ public:
// has only one successor.
raw_ostream &printEdgeProbability(raw_ostream &OS, const BasicBlock *Src,
const BasicBlock *Dst) const;
+
+private:
+ typedef std::pair<const BasicBlock *, const BasicBlock *> Edge;
+
+ // Default weight value. Used when we don't have information about the edge.
+ // TODO: DEFAULT_WEIGHT makes sense during static predication, when none of
+ // the successors have a weight yet. But it doesn't make sense when providing
+ // weight to an edge that may have siblings with non-zero weights. This can
+ // be handled various ways, but it's probably fine for an edge with unknown
+ // weight to just "inherit" the non-zero weight of an adjacent successor.
+ static const uint32_t DEFAULT_WEIGHT = 16;
+
+ DenseMap<Edge, uint32_t> Weights;
+
+ /// \brief Handle to the LoopInfo analysis.
+ LoopInfo *LI;
+
+ /// \brief Track the last function we run over for printing.
+ Function *LastF;
+
+ /// \brief Get sum of the block successors' weights.
+ uint32_t getSumForBlock(const BasicBlock *BB) const;
+
+ bool calcMetadataWeights(BasicBlock *BB);
+ bool calcReturnHeuristics(BasicBlock *BB);
+ bool calcPointerHeuristics(BasicBlock *BB);
+ bool calcLoopBranchHeuristics(BasicBlock *BB);
+ bool calcZeroHeuristics(BasicBlock *BB);
+ bool calcFloatingPointHeuristics(BasicBlock *BB);
};
}