llvm_unreachable->llvm_unreachable(0), LLVM_UNREACHABLE->llvm_unreachable.
[oota-llvm.git] / include / llvm / Analysis / ProfileInfoLoader.h
1 //===- ProfileInfoLoader.h - Load & convert profile information -*- C++ -*-===//
2 //
3 //                      The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
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.
13 //
14 //===----------------------------------------------------------------------===//
15
16 #ifndef LLVM_ANALYSIS_PROFILEINFOLOADER_H
17 #define LLVM_ANALYSIS_PROFILEINFOLOADER_H
18
19 #include <vector>
20 #include <string>
21 #include <utility>
22
23 namespace llvm {
24
25 class Module;
26 class Function;
27 class BasicBlock;
28
29 class ProfileInfoLoader {
30   Module &M;
31   std::vector<std::string> CommandLines;
32   std::vector<unsigned>    FunctionCounts;
33   std::vector<unsigned>    BlockCounts;
34   std::vector<unsigned>    EdgeCounts;
35   std::vector<unsigned>    BBTrace;
36   bool Warned;
37 public:
38   // ProfileInfoLoader ctor - Read the specified profiling data file, exiting
39   // the program if the file is invalid or broken.
40   ProfileInfoLoader(const char *ToolName, const std::string &Filename,
41                     Module &M);
42
43   unsigned getNumExecutions() const { return CommandLines.size(); }
44   const std::string &getExecution(unsigned i) const { return CommandLines[i]; }
45
46   // getFunctionCounts - This method is used by consumers of function counting
47   // information.  If we do not directly have function count information, we
48   // compute it from other, more refined, types of profile information.
49   //
50   void getFunctionCounts(std::vector<std::pair<Function*, unsigned> > &Counts);
51
52   // hasAccurateBlockCounts - Return true if we can synthesize accurate block
53   // frequency information from whatever we have.
54   //
55   bool hasAccurateBlockCounts() const {
56     return !BlockCounts.empty() || !EdgeCounts.empty();
57   }
58
59   // hasAccurateEdgeCounts - Return true if we can synthesize accurate edge
60   // frequency information from whatever we have.
61   //
62   bool hasAccurateEdgeCounts() const {
63     return !EdgeCounts.empty();
64   }
65
66   // getBlockCounts - This method is used by consumers of block counting
67   // information.  If we do not directly have block count information, we
68   // compute it from other, more refined, types of profile information.
69   //
70   void getBlockCounts(std::vector<std::pair<BasicBlock*, unsigned> > &Counts);
71
72   // getEdgeCounts - This method is used by consumers of edge counting
73   // information.  If we do not directly have edge count information, we compute
74   // it from other, more refined, types of profile information.
75   //
76   // Edges are represented as a pair, where the first element is the basic block
77   // and the second element is the successor number.
78   //
79   typedef std::pair<BasicBlock*, unsigned> Edge;
80   void getEdgeCounts(std::vector<std::pair<Edge, unsigned> > &Counts);
81
82   // getBBTrace - This method is used by consumers of basic-block trace
83   // information.
84   //
85   void getBBTrace(std::vector<BasicBlock *> &Trace);
86 };
87
88 } // End llvm namespace
89
90 #endif