1 //=-- InstrProfWriter.h - Instrumented profiling writer -----------*- C++ -*-=//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains support for writing profiling data for instrumentation
11 // based PGO and coverage.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_PROFILEDATA_INSTRPROFWRITER_H
16 #define LLVM_PROFILEDATA_INSTRPROFWRITER_H
18 #include "llvm/ADT/ArrayRef.h"
19 #include "llvm/ADT/DenseMap.h"
20 #include "llvm/ADT/StringMap.h"
21 #include "llvm/ProfileData/InstrProf.h"
22 #include "llvm/Support/DataTypes.h"
23 #include "llvm/Support/raw_ostream.h"
29 /// Writer for instrumentation based profile data.
30 class InstrProfWriter {
32 typedef SmallDenseMap<uint64_t, std::vector<uint64_t>, 1> CounterData;
34 StringMap<CounterData> FunctionData;
35 uint64_t MaxFunctionCount;
37 InstrProfWriter() : MaxFunctionCount(0) {}
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
42 std::error_code addFunctionCounts(StringRef FunctionName,
43 uint64_t FunctionHash,
44 ArrayRef<uint64_t> Counters);
45 /// Ensure that all data is written to disk.
46 void write(raw_fd_ostream &OS);
49 } // end namespace llvm