LLVM  3.7.0
InstrProfWriter.h
Go to the documentation of this file.
1 //=-- InstrProfWriter.h - Instrumented profiling writer -----------*- C++ -*-=//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains support for writing profiling data for instrumentation
11 // based PGO and coverage.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_PROFILEDATA_INSTRPROFWRITER_H
16 #define LLVM_PROFILEDATA_INSTRPROFWRITER_H
17 
18 #include "llvm/ADT/ArrayRef.h"
19 #include "llvm/ADT/DenseMap.h"
20 #include "llvm/ADT/StringMap.h"
22 #include "llvm/Support/DataTypes.h"
25 #include <vector>
26 
27 namespace llvm {
28 
29 /// Writer for instrumentation based profile data.
31 public:
33 private:
34  StringMap<CounterData> FunctionData;
35  uint64_t MaxFunctionCount;
36 public:
37  InstrProfWriter() : MaxFunctionCount(0) {}
38 
39  /// Add function counts for the given function. If there are already counts
40  /// for this function and the hash and number of counts match, each counter is
41  /// summed.
42  std::error_code addFunctionCounts(StringRef FunctionName,
43  uint64_t FunctionHash,
44  ArrayRef<uint64_t> Counters);
45  /// Write the profile to \c OS
46  void write(raw_fd_ostream &OS);
47  /// Write the profile, returning the raw data. For testing.
48  std::unique_ptr<MemoryBuffer> writeBuffer();
49 
50 private:
51  std::pair<uint64_t, uint64_t> writeImpl(raw_ostream &OS);
52 };
53 
54 } // end namespace llvm
55 
56 #endif
SmallDenseMap< uint64_t, std::vector< uint64_t >, 1 > CounterData
Writer for instrumentation based profile data.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
Definition: StringMap.h:214
A raw_ostream that writes to a file descriptor.
Definition: raw_ostream.h:345
std::error_code addFunctionCounts(StringRef FunctionName, uint64_t FunctionHash, ArrayRef< uint64_t > Counters)
Add function counts for the given function.
void write(raw_fd_ostream &OS)
Write the profile to OS.
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:38
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:40
std::unique_ptr< MemoryBuffer > writeBuffer()
Write the profile, returning the raw data. For testing.