blob: db4500127df62f061a5a81d0deb3bd8e8c7d64a2 [file] [log] [blame]
Chris Lattnere4367792003-10-28 20:13:07 +00001//===- 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>
Chris Lattner7a78d812003-10-28 21:08:18 +000020#include <utility>
Brian Gaeked0fde302003-11-11 22:41:34 +000021
22namespace llvm {
23
Chris Lattner7a78d812003-10-28 21:08:18 +000024class Module;
25class Function;
Chris Lattner33f1ca72003-10-28 21:25:23 +000026class BasicBlock;
Chris Lattnere4367792003-10-28 20:13:07 +000027
28class ProfileInfo {
Chris Lattner7a78d812003-10-28 21:08:18 +000029 Module &M;
Chris Lattnere4367792003-10-28 20:13:07 +000030 std::vector<std::string> CommandLines;
31 std::vector<unsigned> FunctionCounts;
32 std::vector<unsigned> BlockCounts;
33public:
34 // ProfileInfo ctor - Read the specified profiling data file, exiting the
35 // program if the file is invalid or broken.
Chris Lattner7a78d812003-10-28 21:08:18 +000036 ProfileInfo(const char *ToolName, const std::string &Filename, Module &M);
37
Chris Lattner4963dcf2003-10-28 22:30:37 +000038 unsigned getNumExecutions() const { return CommandLines.size(); }
39 const std::string &getExecution(unsigned i) const { return CommandLines[i]; }
40
Chris Lattner7a78d812003-10-28 21:08:18 +000041 // 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
Chris Lattner33f1ca72003-10-28 21:25:23 +000047 // 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);
Chris Lattnere4367792003-10-28 20:13:07 +000059};
60
Brian Gaeked0fde302003-11-11 22:41:34 +000061} // End llvm namespace
62
Chris Lattnere4367792003-10-28 20:13:07 +000063#endif