#ifndef LLVM_ANALYSIS_PROFILEDATALOADER_H
#define LLVM_ANALYSIS_PROFILEDATALOADER_H
+#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Debug.h"
class Function;
class BasicBlock;
-// Helpers for dumping edges to dbgs().
+// Helper for dumping edges to dbgs().
raw_ostream& operator<<(raw_ostream &O, std::pair<const BasicBlock *,
const BasicBlock *> E);
-raw_ostream& operator<<(raw_ostream &O, const BasicBlock *BB);
-raw_ostream& operator<<(raw_ostream &O, const Function *F);
/// \brief The ProfileDataT<FType, BType> class is used to store the mapping of
/// profiling data to control flow edges.
/// An edge is defined by its source and sink basic blocks.
template<class FType, class BType>
class ProfileDataT {
- public:
+public:
// The profiling information defines an Edge by its source and sink basic
// blocks.
typedef std::pair<const BType*, const BType*> Edge;
- private:
+private:
typedef DenseMap<Edge, unsigned> EdgeWeights;
/// \brief Count the number of times a transition between two blocks is
/// entry block to indicate how many times the function was entered.
DenseMap<const FType*, EdgeWeights> EdgeInformation;
- public:
- static char ID; // Class identification, replacement for typeinfo
- ProfileDataT() {};
- ~ProfileDataT() {};
-
+public:
/// getFunction() - Returns the Function for an Edge.
static const FType *getFunction(Edge e) {
// e.first may be NULL
/// addEdgeWeight - Add 'weight' to the already stored execution count for
/// this edge.
void addEdgeWeight(Edge e, unsigned weight) {
- EdgeInformation[getFunction(e)][e] += weight;
+ EdgeInformation[getFunction(e)][e] += weight;
}
};
/// been counted yet.
static const unsigned Uncounted;
- /// The maximum value that can be stored in a profiling counter.
- static const unsigned MaxCount;
-
/// getNumExecutions - Return the number of times the target program was run
/// to generate this profiling data.
unsigned getNumExecutions() const { return CommandLines.size(); }
/// getRawEdgeCounts - Return the raw profiling data, this is just a list of
/// numbers with no mappings to edges.
- const SmallVector<unsigned, 32> &getRawEdgeCounts() const { return EdgeCounts; }
+ ArrayRef<unsigned> getRawEdgeCounts() const { return EdgeCounts; }
};
/// createProfileMetadataLoaderPass - This function returns a Pass that loads