Chris Lattner | e436779 | 2003-10-28 20:13:07 +0000 | [diff] [blame] | 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> |
Chris Lattner | 7a78d81 | 2003-10-28 21:08:18 +0000 | [diff] [blame] | 20 | #include <utility> |
| 21 | class Module; |
| 22 | class Function; |
Chris Lattner | 33f1ca7 | 2003-10-28 21:25:23 +0000 | [diff] [blame] | 23 | class BasicBlock; |
Chris Lattner | e436779 | 2003-10-28 20:13:07 +0000 | [diff] [blame] | 24 | |
| 25 | class ProfileInfo { |
Chris Lattner | 7a78d81 | 2003-10-28 21:08:18 +0000 | [diff] [blame] | 26 | Module &M; |
Chris Lattner | e436779 | 2003-10-28 20:13:07 +0000 | [diff] [blame] | 27 | std::vector<std::string> CommandLines; |
| 28 | std::vector<unsigned> FunctionCounts; |
| 29 | std::vector<unsigned> BlockCounts; |
| 30 | public: |
| 31 | // ProfileInfo ctor - Read the specified profiling data file, exiting the |
| 32 | // program if the file is invalid or broken. |
Chris Lattner | 7a78d81 | 2003-10-28 21:08:18 +0000 | [diff] [blame] | 33 | ProfileInfo(const char *ToolName, const std::string &Filename, Module &M); |
| 34 | |
Chris Lattner | 4963dcf | 2003-10-28 22:30:37 +0000 | [diff] [blame^] | 35 | unsigned getNumExecutions() const { return CommandLines.size(); } |
| 36 | const std::string &getExecution(unsigned i) const { return CommandLines[i]; } |
| 37 | |
Chris Lattner | 7a78d81 | 2003-10-28 21:08:18 +0000 | [diff] [blame] | 38 | // getFunctionCounts - This method is used by consumers of function counting |
| 39 | // information. If we do not directly have function count information, we |
| 40 | // compute it from other, more refined, types of profile information. |
| 41 | // |
| 42 | void getFunctionCounts(std::vector<std::pair<Function*, unsigned> > &Counts); |
| 43 | |
Chris Lattner | 33f1ca7 | 2003-10-28 21:25:23 +0000 | [diff] [blame] | 44 | // hasAccurateBlockCounts - Return true if we can synthesize accurate block |
| 45 | // frequency information from whatever we have. |
| 46 | // |
| 47 | bool hasAccurateBlockCounts() const { |
| 48 | return !BlockCounts.empty(); |
| 49 | } |
| 50 | |
| 51 | // getBlockCounts - This method is used by consumers of block counting |
| 52 | // information. If we do not directly have block count information, we |
| 53 | // compute it from other, more refined, types of profile information. |
| 54 | // |
| 55 | void getBlockCounts(std::vector<std::pair<BasicBlock*, unsigned> > &Counts); |
Chris Lattner | e436779 | 2003-10-28 20:13:07 +0000 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | #endif |