Allow C++ programs to end in .cc. This allows C++ test programs in the
[oota-llvm.git] / tools / llvm-prof / ProfileInfo.h
1 //===- ProfileInfo.h - Represents profile information -----------*- C++ -*-===//
2 // 
3 //                      The LLVM Compiler Infrastructure
4 //
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.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // The ProfileInfo class is used to represent profiling information read in from
11 // the dump file.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef PROFILEINFO_H
16 #define PROFILEINFO_H
17
18 #include <vector>
19 #include <string>
20 #include <utility>
21
22 namespace llvm {
23
24 class Module;
25 class Function;
26 class BasicBlock;
27
28 class ProfileInfo {
29   Module &M;
30   std::vector<std::string> CommandLines;
31   std::vector<unsigned>    FunctionCounts;
32   std::vector<unsigned>    BlockCounts;
33 public:
34   // ProfileInfo ctor - Read the specified profiling data file, exiting the
35   // program if the file is invalid or broken.
36   ProfileInfo(const char *ToolName, const std::string &Filename, Module &M);
37
38   unsigned getNumExecutions() const { return CommandLines.size(); }
39   const std::string &getExecution(unsigned i) const { return CommandLines[i]; }
40
41   // getFunctionCounts - This method is used by consumers of function counting
42   // information.  If we do not directly have function count information, we
43   // compute it from other, more refined, types of profile information.
44   //
45   void getFunctionCounts(std::vector<std::pair<Function*, unsigned> > &Counts);
46
47   // hasAccurateBlockCounts - Return true if we can synthesize accurate block
48   // frequency information from whatever we have.
49   //
50   bool hasAccurateBlockCounts() const {
51     return !BlockCounts.empty();
52   }
53
54   // getBlockCounts - This method is used by consumers of block counting
55   // information.  If we do not directly have block count information, we
56   // compute it from other, more refined, types of profile information.
57   //
58   void getBlockCounts(std::vector<std::pair<BasicBlock*, unsigned> > &Counts);
59 };
60
61 } // End llvm namespace
62
63 #endif