LLVM API Documentation
00001 //===- ProfileInfoLoader.h - Load & convert profile information -*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file was developed by the LLVM research group and is distributed under 00006 // the University of Illinois Open Source License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // The ProfileInfoLoader class is used to load and represent profiling 00011 // information read in from the dump file. If conversions between formats are 00012 // needed, it can also do this. 00013 // 00014 //===----------------------------------------------------------------------===// 00015 00016 #ifndef LLVM_ANALYSIS_PROFILEINFOLOADER_H 00017 #define LLVM_ANALYSIS_PROFILEINFOLOADER_H 00018 00019 #include <vector> 00020 #include <string> 00021 #include <utility> 00022 00023 namespace llvm { 00024 00025 class Module; 00026 class Function; 00027 class BasicBlock; 00028 00029 class ProfileInfoLoader { 00030 Module &M; 00031 std::vector<std::string> CommandLines; 00032 std::vector<unsigned> FunctionCounts; 00033 std::vector<unsigned> BlockCounts; 00034 std::vector<unsigned> EdgeCounts; 00035 std::vector<unsigned> BBTrace; 00036 public: 00037 // ProfileInfoLoader ctor - Read the specified profiling data file, exiting 00038 // the program if the file is invalid or broken. 00039 ProfileInfoLoader(const char *ToolName, const std::string &Filename, 00040 Module &M); 00041 00042 unsigned getNumExecutions() const { return CommandLines.size(); } 00043 const std::string &getExecution(unsigned i) const { return CommandLines[i]; } 00044 00045 // getFunctionCounts - This method is used by consumers of function counting 00046 // information. If we do not directly have function count information, we 00047 // compute it from other, more refined, types of profile information. 00048 // 00049 void getFunctionCounts(std::vector<std::pair<Function*, unsigned> > &Counts); 00050 00051 // hasAccurateBlockCounts - Return true if we can synthesize accurate block 00052 // frequency information from whatever we have. 00053 // 00054 bool hasAccurateBlockCounts() const { 00055 return !BlockCounts.empty() || !EdgeCounts.empty(); 00056 } 00057 00058 // hasAccurateEdgeCounts - Return true if we can synthesize accurate edge 00059 // frequency information from whatever we have. 00060 // 00061 bool hasAccurateEdgeCounts() const { 00062 return !EdgeCounts.empty(); 00063 } 00064 00065 // getBlockCounts - This method is used by consumers of block counting 00066 // information. If we do not directly have block count information, we 00067 // compute it from other, more refined, types of profile information. 00068 // 00069 void getBlockCounts(std::vector<std::pair<BasicBlock*, unsigned> > &Counts); 00070 00071 // getEdgeCounts - This method is used by consumers of edge counting 00072 // information. If we do not directly have edge count information, we compute 00073 // it from other, more refined, types of profile information. 00074 // 00075 // Edges are represented as a pair, where the first element is the basic block 00076 // and the second element is the successor number. 00077 // 00078 typedef std::pair<BasicBlock*, unsigned> Edge; 00079 void getEdgeCounts(std::vector<std::pair<Edge, unsigned> > &Counts); 00080 00081 // getBBTrace - This method is used by consumers of basic-block trace 00082 // information. 00083 // 00084 void getBBTrace(std::vector<BasicBlock *> &Trace); 00085 }; 00086 00087 } // End llvm namespace 00088 00089 #endif