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> |
Brian Gaeke | d0fde30 | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 21 | |
| 22 | namespace llvm { |
| 23 | |
Chris Lattner | 7a78d81 | 2003-10-28 21:08:18 +0000 | [diff] [blame] | 24 | class Module; |
| 25 | class Function; |
Chris Lattner | 33f1ca7 | 2003-10-28 21:25:23 +0000 | [diff] [blame] | 26 | class BasicBlock; |
Chris Lattner | e436779 | 2003-10-28 20:13:07 +0000 | [diff] [blame] | 27 | |
| 28 | class ProfileInfo { |
Chris Lattner | 7a78d81 | 2003-10-28 21:08:18 +0000 | [diff] [blame] | 29 | Module &M; |
Chris Lattner | e436779 | 2003-10-28 20:13:07 +0000 | [diff] [blame] | 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. |
Chris Lattner | 7a78d81 | 2003-10-28 21:08:18 +0000 | [diff] [blame] | 36 | ProfileInfo(const char *ToolName, const std::string &Filename, Module &M); |
| 37 | |
Chris Lattner | 4963dcf | 2003-10-28 22:30:37 +0000 | [diff] [blame] | 38 | unsigned getNumExecutions() const { return CommandLines.size(); } |
| 39 | const std::string &getExecution(unsigned i) const { return CommandLines[i]; } |
| 40 | |
Chris Lattner | 7a78d81 | 2003-10-28 21:08:18 +0000 | [diff] [blame] | 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 | |
Chris Lattner | 33f1ca7 | 2003-10-28 21:25:23 +0000 | [diff] [blame] | 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); |
Chris Lattner | e436779 | 2003-10-28 20:13:07 +0000 | [diff] [blame] | 59 | }; |
| 60 | |
Brian Gaeke | d0fde30 | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 61 | } // End llvm namespace |
| 62 | |
Chris Lattner | e436779 | 2003-10-28 20:13:07 +0000 | [diff] [blame] | 63 | #endif |