LLVM API Documentation
00001 //=-- InstrProfWriter.h - Instrumented profiling writer -----------*- C++ -*-=// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file contains support for writing profiling data for instrumentation 00011 // based PGO and coverage. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #ifndef LLVM_PROFILEDATA_INSTRPROFWRITER_H 00016 #define LLVM_PROFILEDATA_INSTRPROFWRITER_H 00017 00018 #include "llvm/ADT/ArrayRef.h" 00019 #include "llvm/ADT/DenseMap.h" 00020 #include "llvm/ADT/StringMap.h" 00021 #include "llvm/ProfileData/InstrProf.h" 00022 #include "llvm/Support/DataTypes.h" 00023 #include "llvm/Support/raw_ostream.h" 00024 00025 #include <vector> 00026 00027 namespace llvm { 00028 00029 /// Writer for instrumentation based profile data. 00030 class InstrProfWriter { 00031 public: 00032 typedef SmallDenseMap<uint64_t, std::vector<uint64_t>, 1> CounterData; 00033 private: 00034 StringMap<CounterData> FunctionData; 00035 uint64_t MaxFunctionCount; 00036 public: 00037 InstrProfWriter() : MaxFunctionCount(0) {} 00038 00039 /// Add function counts for the given function. If there are already counts 00040 /// for this function and the hash and number of counts match, each counter is 00041 /// summed. 00042 std::error_code addFunctionCounts(StringRef FunctionName, 00043 uint64_t FunctionHash, 00044 ArrayRef<uint64_t> Counters); 00045 /// Ensure that all data is written to disk. 00046 void write(raw_fd_ostream &OS); 00047 }; 00048 00049 } // end namespace llvm 00050 00051 #endif