mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 02:33:33 +00:00
This patch cleans up the ProfileInfo by
*) introducing new data type and export function of edge info for whole function (preparation for next patch). *) renaming variables to make clear distinction between data and containers that contain this data. *) updated comments and whitespaces. *) made ProfileInfo::MissingValue a double (as it should be...). (Discussed at http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20090817/084955.html.) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79940 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
fd7a918e58
commit
96135b617a
@ -36,20 +36,21 @@ namespace llvm {
|
||||
public:
|
||||
// Types for handling profiling information.
|
||||
typedef std::pair<const BasicBlock*, const BasicBlock*> Edge;
|
||||
typedef std::map<Edge, double> EdgeCounts;
|
||||
typedef std::pair<Edge, double> EdgeWeight;
|
||||
typedef std::map<Edge, double> EdgeWeights;
|
||||
typedef std::map<const BasicBlock*, double> BlockCounts;
|
||||
|
||||
protected:
|
||||
// EdgeCounts - Count the number of times a transition between two blocks is
|
||||
// executed. As a special case, we also hold an edge from the null
|
||||
// BasicBlock to the entry block to indicate how many times the function was
|
||||
// entered.
|
||||
std::map<const Function*, EdgeCounts> EdgeInformation;
|
||||
// EdgeInformation - Count the number of times a transition between two
|
||||
// blocks is executed. As a special case, we also hold an edge from the
|
||||
// null BasicBlock to the entry block to indicate how many times the
|
||||
// function was entered.
|
||||
std::map<const Function*, EdgeWeights> EdgeInformation;
|
||||
|
||||
// BlockCounts - Count the number of times a block is executed.
|
||||
// BlockInformation - Count the number of times a block is executed.
|
||||
std::map<const Function*, BlockCounts> BlockInformation;
|
||||
|
||||
// FunctionCounts - Count the number of times a function is executed.
|
||||
// FunctionInformation - Count the number of times a function is executed.
|
||||
std::map<const Function*, double> FunctionInformation;
|
||||
public:
|
||||
static char ID; // Class identification, replacement for typeinfo
|
||||
@ -57,7 +58,7 @@ namespace llvm {
|
||||
|
||||
// MissingValue - The value that is returned for execution counts in case
|
||||
// no value is available.
|
||||
static const int MissingValue = -1;
|
||||
static const double MissingValue;
|
||||
|
||||
// getFunction() - Returns the Function for an Edge, checking for validity.
|
||||
static const Function* getFunction(Edge e) {
|
||||
@ -66,7 +67,7 @@ namespace llvm {
|
||||
}
|
||||
|
||||
// getEdge() - Creates an Edge from two BasicBlocks.
|
||||
static Edge getEdge(const BasicBlock* Src, const BasicBlock* Dest) {
|
||||
static Edge getEdge(const BasicBlock *Src, const BasicBlock *Dest) {
|
||||
return std::make_pair(Src, Dest);
|
||||
}
|
||||
|
||||
@ -78,16 +79,20 @@ namespace llvm {
|
||||
double getExecutionCount(const BasicBlock *BB);
|
||||
|
||||
double getEdgeWeight(Edge e) const {
|
||||
std::map<const Function*, EdgeCounts>::const_iterator J =
|
||||
std::map<const Function*, EdgeWeights>::const_iterator J =
|
||||
EdgeInformation.find(getFunction(e));
|
||||
if (J == EdgeInformation.end()) return MissingValue;
|
||||
|
||||
EdgeCounts::const_iterator I = J->second.find(e);
|
||||
EdgeWeights::const_iterator I = J->second.find(e);
|
||||
if (I == J->second.end()) return MissingValue;
|
||||
|
||||
return I->second;
|
||||
}
|
||||
|
||||
EdgeWeights &getEdgeWeights (const Function *F) {
|
||||
return EdgeInformation[F];
|
||||
}
|
||||
|
||||
//===------------------------------------------------------------------===//
|
||||
/// Analysis Update Methods
|
||||
///
|
||||
|
@ -26,6 +26,8 @@ char ProfileInfo::ID = 0;
|
||||
|
||||
ProfileInfo::~ProfileInfo() {}
|
||||
|
||||
const double ProfileInfo::MissingValue = -1;
|
||||
|
||||
double ProfileInfo::getExecutionCount(const BasicBlock *BB) {
|
||||
std::map<const Function*, BlockCounts>::iterator J =
|
||||
BlockInformation.find(BB->getParent());
|
||||
@ -60,7 +62,7 @@ double ProfileInfo::getExecutionCount(const BasicBlock *BB) {
|
||||
Count += w;
|
||||
}
|
||||
|
||||
BlockInformation[BB->getParent()][BB] = Count;
|
||||
if (Count != MissingValue) BlockInformation[BB->getParent()][BB] = Count;
|
||||
return Count;
|
||||
}
|
||||
|
||||
@ -72,7 +74,7 @@ double ProfileInfo::getExecutionCount(const Function *F) {
|
||||
return J->second;
|
||||
|
||||
double Count = getExecutionCount(&F->getEntryBlock());
|
||||
FunctionInformation[F] = Count;
|
||||
if (Count != MissingValue) FunctionInformation[F] = Count;
|
||||
return Count;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user