1 //===- ProfileInfoLoader.h - Load & convert profile information -*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // The ProfileInfoLoader class is used to load and represent profiling
11 // information read in from the dump file. If conversions between formats are
12 // needed, it can also do this.
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_ANALYSIS_PROFILEINFOLOADER_H
17 #define LLVM_ANALYSIS_PROFILEINFOLOADER_H
29 class ProfileInfoLoader {
31 std::vector<std::string> CommandLines;
32 std::vector<unsigned> FunctionCounts;
33 std::vector<unsigned> BlockCounts;
34 std::vector<unsigned> EdgeCounts;
36 // ProfileInfoLoader ctor - Read the specified profiling data file, exiting
37 // the program if the file is invalid or broken.
38 ProfileInfoLoader(const char *ToolName, const std::string &Filename,
41 unsigned getNumExecutions() const { return CommandLines.size(); }
42 const std::string &getExecution(unsigned i) const { return CommandLines[i]; }
44 // getFunctionCounts - This method is used by consumers of function counting
45 // information. If we do not directly have function count information, we
46 // compute it from other, more refined, types of profile information.
48 void getFunctionCounts(std::vector<std::pair<Function*, unsigned> > &Counts);
50 // hasAccurateBlockCounts - Return true if we can synthesize accurate block
51 // frequency information from whatever we have.
53 bool hasAccurateBlockCounts() const {
54 return !BlockCounts.empty() || !EdgeCounts.empty();
57 // hasAccurateEdgeCounts - Return true if we can synthesize accurate edge
58 // frequency information from whatever we have.
60 bool hasAccurateEdgeCounts() const {
61 return !EdgeCounts.empty();
64 // getBlockCounts - This method is used by consumers of block counting
65 // information. If we do not directly have block count information, we
66 // compute it from other, more refined, types of profile information.
68 void getBlockCounts(std::vector<std::pair<BasicBlock*, unsigned> > &Counts);
70 // getEdgeCounts - This method is used by consumers of edge counting
71 // information. If we do not directly have edge count information, we compute
72 // it from other, more refined, types of profile information.
74 // Edges are represented as a pair, where the first element is the basic block
75 // and the second element is the successor number.
77 typedef std::pair<BasicBlock*, unsigned> Edge;
78 void getEdgeCounts(std::vector<std::pair<Edge, unsigned> > &Counts);
81 } // End llvm namespace