Move two Value Profiler data structs to InstrProfData.inc (NFC)
[oota-llvm.git] / include / llvm / ProfileData / InstrProf.h
1 //=-- InstrProf.h - Instrumented profiling format support ---------*- 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 // Instrumentation-based profiling data is generated by instrumented
11 // binaries through library functions in compiler-rt, and read by the clang
12 // frontend to feed PGO.
13 //
14 //===----------------------------------------------------------------------===//
15
16 #ifndef LLVM_PROFILEDATA_INSTRPROF_H_
17 #define LLVM_PROFILEDATA_INSTRPROF_H_
18
19 #include "llvm/ADT/StringRef.h"
20 #include "llvm/ADT/StringSet.h"
21 #include "llvm/IR/GlobalValue.h"
22 #include "llvm/ProfileData/InstrProfData.inc"
23 #include "llvm/Support/Endian.h"
24 #include "llvm/Support/ErrorHandling.h"
25 #include "llvm/Support/ErrorOr.h"
26 #include "llvm/Support/MD5.h"
27 #include <cstdint>
28 #include <list>
29 #include <system_error>
30 #include <vector>
31
32 namespace llvm {
33
34 class Function;
35 class GlobalVariable;
36 class Module;
37
38 /// Return the name of data section containing profile counter variables.
39 inline StringRef getInstrProfCountersSectionName(bool AddSegment) {
40   return AddSegment ? "__DATA," INSTR_PROF_CNTS_SECT_NAME_STR
41                     : INSTR_PROF_CNTS_SECT_NAME_STR;
42 }
43
44 /// Return the name of data section containing names of instrumented
45 /// functions.
46 inline StringRef getInstrProfNameSectionName(bool AddSegment) {
47   return AddSegment ? "__DATA," INSTR_PROF_NAME_SECT_NAME_STR
48                     : INSTR_PROF_NAME_SECT_NAME_STR;
49 }
50
51 /// Return the name of the data section containing per-function control
52 /// data.
53 inline StringRef getInstrProfDataSectionName(bool AddSegment) {
54   return AddSegment ? "__DATA," INSTR_PROF_DATA_SECT_NAME_STR
55                     : INSTR_PROF_DATA_SECT_NAME_STR;
56 }
57
58 /// Return the name profile runtime entry point to do value profiling
59 /// for a given site.
60 inline StringRef getInstrProfValueProfFuncName() {
61   return INSTR_PROF_VALUE_PROF_FUNC_STR;
62 }
63
64 /// Return the name of the section containing function coverage mapping
65 /// data.
66 inline StringRef getInstrProfCoverageSectionName(bool AddSegment) {
67   return AddSegment ? "__DATA,__llvm_covmap" : "__llvm_covmap";
68 }
69
70 /// Return the name prefix of variables containing instrumented function names.
71 inline StringRef getInstrProfNameVarPrefix() { return "__llvm_profile_name_"; }
72
73 /// Return the name prefix of variables containing per-function control data.
74 inline StringRef getInstrProfDataVarPrefix() { return "__llvm_profile_data_"; }
75
76 /// Return the name prefix of profile counter variables.
77 inline StringRef getInstrProfCountersVarPrefix() {
78   return "__llvm_profile_counters_";
79 }
80
81 /// Return the name prefix of the COMDAT group for instrumentation variables
82 /// associated with a COMDAT function.
83 inline StringRef getInstrProfComdatPrefix() { return "__llvm_profile_vars_"; }
84
85 /// Return the name of a covarage mapping variable (internal linkage) 
86 /// for each instrumented source module. Such variables are allocated
87 /// in the __llvm_covmap section.
88 inline StringRef getCoverageMappingVarName() {
89   return "__llvm_coverage_mapping";
90 }
91
92 /// Return the name of function that registers all the per-function control
93 /// data at program startup time by calling __llvm_register_function. This
94 /// function has internal linkage and is called by  __llvm_profile_init
95 /// runtime method. This function is not generated for these platforms:
96 /// Darwin, Linux, and FreeBSD.
97 inline StringRef getInstrProfRegFuncsName() {
98   return "__llvm_profile_register_functions";
99 }
100
101 /// Return the name of the runtime interface that registers per-function control
102 /// data for one instrumented function.
103 inline StringRef getInstrProfRegFuncName() {
104   return "__llvm_profile_register_function";
105 }
106
107 /// Return the name of the runtime initialization method that is generated by
108 /// the compiler. The function calls __llvm_profile_register_functions and
109 /// __llvm_profile_override_default_filename functions if needed. This function
110 /// has internal linkage and invoked at startup time via init_array.
111 inline StringRef getInstrProfInitFuncName() { return "__llvm_profile_init"; }
112
113 /// Return the name of the hook variable defined in profile runtime library.
114 /// A reference to the variable causes the linker to link in the runtime
115 /// initialization module (which defines the hook variable).
116 inline StringRef getInstrProfRuntimeHookVarName() {
117   return "__llvm_profile_runtime";
118 }
119
120 /// Return the name of the compiler generated function that references the
121 /// runtime hook variable. The function is a weak global.
122 inline StringRef getInstrProfRuntimeHookVarUseFuncName() {
123   return "__llvm_profile_runtime_user";
124 }
125
126 /// Return the name of the profile runtime interface that overrides the default
127 /// profile data file name.
128 inline StringRef getInstrProfFileOverriderFuncName() {
129   return "__llvm_profile_override_default_filename";
130 }
131
132 /// Return the modified name for function \c F suitable to be
133 /// used the key for profile lookup.
134 std::string getPGOFuncName(const Function &F);
135
136 /// Return the modified name for a function suitable to be
137 /// used the key for profile lookup. The function's original
138 /// name is \c RawFuncName and has linkage of type \c Linkage.
139 /// The function is defined in module \c FileName.
140 std::string getPGOFuncName(StringRef RawFuncName,
141                            GlobalValue::LinkageTypes Linkage,
142                            StringRef FileName);
143
144 /// Create and return the global variable for function name used in PGO
145 /// instrumentation. \c FuncName is the name of the function returned
146 /// by \c getPGOFuncName call.
147 GlobalVariable *createPGOFuncNameVar(Function &F, StringRef FuncName);
148
149 /// Create and return the global variable for function name used in PGO
150 /// instrumentation.  /// \c FuncName is the name of the function
151 /// returned by \c getPGOFuncName call, \c M is the owning module,
152 /// and \c Linkage is the linkage of the instrumented function.
153 GlobalVariable *createPGOFuncNameVar(Module &M,
154                                      GlobalValue::LinkageTypes Linkage,
155                                      StringRef FuncName);
156
157 const std::error_category &instrprof_category();
158
159 enum class instrprof_error {
160   success = 0,
161   eof,
162   unrecognized_format,
163   bad_magic,
164   bad_header,
165   unsupported_version,
166   unsupported_hash_type,
167   too_large,
168   truncated,
169   malformed,
170   unknown_function,
171   hash_mismatch,
172   count_mismatch,
173   counter_overflow,
174   value_site_count_mismatch
175 };
176
177 inline std::error_code make_error_code(instrprof_error E) {
178   return std::error_code(static_cast<int>(E), instrprof_category());
179 }
180
181 enum InstrProfValueKind : uint32_t {
182 #define VALUE_PROF_KIND(Enumerator, Value) Enumerator = Value,
183 #include "llvm/ProfileData/InstrProfData.inc"
184 };
185
186 struct InstrProfStringTable {
187   // Set of string values in profiling data.
188   StringSet<> StringValueSet;
189   InstrProfStringTable() { StringValueSet.clear(); }
190   // Get a pointer to internal storage of a string in set
191   const char *getStringData(StringRef Str) {
192     auto Result = StringValueSet.find(Str);
193     return (Result == StringValueSet.end()) ? nullptr : Result->first().data();
194   }
195   // Insert a string to StringTable
196   const char *insertString(StringRef Str) {
197     auto Result = StringValueSet.insert(Str);
198     return Result.first->first().data();
199   }
200 };
201
202 struct InstrProfValueSiteRecord {
203   /// Value profiling data pairs at a given value site.
204   std::list<InstrProfValueData> ValueData;
205
206   InstrProfValueSiteRecord() { ValueData.clear(); }
207   template <class InputIterator>
208   InstrProfValueSiteRecord(InputIterator F, InputIterator L)
209       : ValueData(F, L) {}
210
211   /// Sort ValueData ascending by Value
212   void sortByTargetValues() {
213     ValueData.sort(
214         [](const InstrProfValueData &left, const InstrProfValueData &right) {
215           return left.Value < right.Value;
216         });
217   }
218
219   /// Merge data from another InstrProfValueSiteRecord
220   void mergeValueData(InstrProfValueSiteRecord &Input) {
221     this->sortByTargetValues();
222     Input.sortByTargetValues();
223     auto I = ValueData.begin();
224     auto IE = ValueData.end();
225     for (auto J = Input.ValueData.begin(), JE = Input.ValueData.end(); J != JE;
226          ++J) {
227       while (I != IE && I->Value < J->Value)
228         ++I;
229       if (I != IE && I->Value == J->Value) {
230         I->Count = SaturatingAdd(I->Count, J->Count);
231         ++I;
232         continue;
233       }
234       ValueData.insert(I, *J);
235     }
236   }
237 };
238
239 /// Profiling information for a single function.
240 struct InstrProfRecord {
241   InstrProfRecord() {}
242   InstrProfRecord(StringRef Name, uint64_t Hash, std::vector<uint64_t> Counts)
243       : Name(Name), Hash(Hash), Counts(std::move(Counts)) {}
244   StringRef Name;
245   uint64_t Hash;
246   std::vector<uint64_t> Counts;
247
248   typedef std::vector<std::pair<uint64_t, const char *>> ValueMapType;
249
250   /// Return the number of value profile kinds with non-zero number
251   /// of profile sites.
252   inline uint32_t getNumValueKinds() const;
253   /// Return the number of instrumented sites for ValueKind.
254   inline uint32_t getNumValueSites(uint32_t ValueKind) const;
255   /// Return the total number of ValueData for ValueKind.
256   inline uint32_t getNumValueData(uint32_t ValueKind) const;
257   /// Return the number of value data collected for ValueKind at profiling
258   /// site: Site.
259   inline uint32_t getNumValueDataForSite(uint32_t ValueKind,
260                                          uint32_t Site) const;
261   inline std::unique_ptr<InstrProfValueData[]>
262   getValueForSite(uint32_t ValueKind, uint32_t Site) const;
263   /// Reserve space for NumValueSites sites.
264   inline void reserveSites(uint32_t ValueKind, uint32_t NumValueSites);
265   /// Add ValueData for ValueKind at value Site.
266   inline void addValueData(uint32_t ValueKind, uint32_t Site,
267                            InstrProfValueData *VData, uint32_t N,
268                            ValueMapType *HashKeys);
269
270   /// Merge the counts in \p Other into this one.
271   inline instrprof_error merge(InstrProfRecord &Other);
272
273   /// Used by InstrProfWriter: update the value strings to commoned strings in
274   /// the writer instance.
275   inline void updateStrings(InstrProfStringTable *StrTab);
276
277   /// Clear value data entries
278   inline void clearValueData() {
279     for (uint32_t Kind = IPVK_First; Kind <= IPVK_Last; ++Kind)
280       getValueSitesForKind(Kind).clear();
281   }
282
283 private:
284   std::vector<InstrProfValueSiteRecord> IndirectCallSites;
285   const std::vector<InstrProfValueSiteRecord> &
286   getValueSitesForKind(uint32_t ValueKind) const {
287     switch (ValueKind) {
288     case IPVK_IndirectCallTarget:
289       return IndirectCallSites;
290     default:
291       llvm_unreachable("Unknown value kind!");
292     }
293     return IndirectCallSites;
294   }
295
296   std::vector<InstrProfValueSiteRecord> &
297   getValueSitesForKind(uint32_t ValueKind) {
298     return const_cast<std::vector<InstrProfValueSiteRecord> &>(
299         const_cast<const InstrProfRecord *>(this)
300             ->getValueSitesForKind(ValueKind));
301   }
302
303   // Map indirect call target name hash to name string.
304   uint64_t remapValue(uint64_t Value, uint32_t ValueKind,
305                       ValueMapType *HashKeys) {
306     if (!HashKeys)
307       return Value;
308     switch (ValueKind) {
309     case IPVK_IndirectCallTarget: {
310       auto Result =
311           std::lower_bound(HashKeys->begin(), HashKeys->end(), Value,
312                            [](const std::pair<uint64_t, const char *> &LHS,
313                               uint64_t RHS) { return LHS.first < RHS; });
314       if (Result != HashKeys->end())
315         Value = (uint64_t)Result->second;
316       break;
317     }
318     }
319     return Value;
320   }
321
322   // Merge Value Profile data from Src record to this record for ValueKind.
323   instrprof_error mergeValueProfData(uint32_t ValueKind, InstrProfRecord &Src) {
324     uint32_t ThisNumValueSites = getNumValueSites(ValueKind);
325     uint32_t OtherNumValueSites = Src.getNumValueSites(ValueKind);
326     if (ThisNumValueSites != OtherNumValueSites)
327       return instrprof_error::value_site_count_mismatch;
328     std::vector<InstrProfValueSiteRecord> &ThisSiteRecords =
329         getValueSitesForKind(ValueKind);
330     std::vector<InstrProfValueSiteRecord> &OtherSiteRecords =
331         Src.getValueSitesForKind(ValueKind);
332     for (uint32_t I = 0; I < ThisNumValueSites; I++)
333       ThisSiteRecords[I].mergeValueData(OtherSiteRecords[I]);
334     return instrprof_error::success;
335   }
336 };
337
338 uint32_t InstrProfRecord::getNumValueKinds() const {
339   uint32_t NumValueKinds = 0;
340   for (uint32_t Kind = IPVK_First; Kind <= IPVK_Last; ++Kind)
341     NumValueKinds += !(getValueSitesForKind(Kind).empty());
342   return NumValueKinds;
343 }
344
345 uint32_t InstrProfRecord::getNumValueData(uint32_t ValueKind) const {
346   uint32_t N = 0;
347   const std::vector<InstrProfValueSiteRecord> &SiteRecords =
348       getValueSitesForKind(ValueKind);
349   for (auto &SR : SiteRecords) {
350     N += SR.ValueData.size();
351   }
352   return N;
353 }
354
355 uint32_t InstrProfRecord::getNumValueSites(uint32_t ValueKind) const {
356   return getValueSitesForKind(ValueKind).size();
357 }
358
359 uint32_t InstrProfRecord::getNumValueDataForSite(uint32_t ValueKind,
360                                                  uint32_t Site) const {
361   return getValueSitesForKind(ValueKind)[Site].ValueData.size();
362 }
363
364 std::unique_ptr<InstrProfValueData[]>
365 InstrProfRecord::getValueForSite(uint32_t ValueKind, uint32_t Site) const {
366   uint32_t N = getNumValueDataForSite(ValueKind, Site);
367   if (N == 0)
368     return std::unique_ptr<InstrProfValueData[]>(nullptr);
369
370   std::unique_ptr<InstrProfValueData[]> VD(new InstrProfValueData[N]);
371   uint32_t I = 0;
372   for (auto V : getValueSitesForKind(ValueKind)[Site].ValueData) {
373     VD[I] = V;
374     I++;
375   }
376   assert(I == N);
377
378   return VD;
379 }
380
381 void InstrProfRecord::addValueData(uint32_t ValueKind, uint32_t Site,
382                                    InstrProfValueData *VData, uint32_t N,
383                                    ValueMapType *HashKeys) {
384   for (uint32_t I = 0; I < N; I++) {
385     VData[I].Value = remapValue(VData[I].Value, ValueKind, HashKeys);
386   }
387   std::vector<InstrProfValueSiteRecord> &ValueSites =
388       getValueSitesForKind(ValueKind);
389   if (N == 0)
390     ValueSites.push_back(InstrProfValueSiteRecord());
391   else
392     ValueSites.emplace_back(VData, VData + N);
393 }
394
395 void InstrProfRecord::reserveSites(uint32_t ValueKind, uint32_t NumValueSites) {
396   std::vector<InstrProfValueSiteRecord> &ValueSites =
397       getValueSitesForKind(ValueKind);
398   ValueSites.reserve(NumValueSites);
399 }
400
401 void InstrProfRecord::updateStrings(InstrProfStringTable *StrTab) {
402   if (!StrTab)
403     return;
404
405   Name = StrTab->insertString(Name);
406   for (auto &VSite : IndirectCallSites)
407     for (auto &VData : VSite.ValueData)
408       VData.Value = (uint64_t)StrTab->insertString((const char *)VData.Value);
409 }
410
411 instrprof_error InstrProfRecord::merge(InstrProfRecord &Other) {
412   // If the number of counters doesn't match we either have bad data
413   // or a hash collision.
414   if (Counts.size() != Other.Counts.size())
415     return instrprof_error::count_mismatch;
416
417   for (size_t I = 0, E = Other.Counts.size(); I < E; ++I) {
418     if (Counts[I] + Other.Counts[I] < Counts[I])
419       return instrprof_error::counter_overflow;
420     Counts[I] += Other.Counts[I];
421   }
422
423   for (uint32_t Kind = IPVK_First; Kind <= IPVK_Last; ++Kind) {
424     instrprof_error result = mergeValueProfData(Kind, Other);
425     if (result != instrprof_error::success)
426       return result;
427   }
428
429   return instrprof_error::success;
430 }
431
432 inline support::endianness getHostEndianness() {
433   return sys::IsLittleEndianHost ? support::little : support::big;
434 }
435
436 /// This is the header of the data structure that defines the on-disk
437 /// layout of the value profile data of a particular kind for one function.
438 struct ValueProfRecord {
439   // The kind of the value profile record.
440   uint32_t Kind;
441   // The number of value profile sites. It is guaranteed to be non-zero;
442   // otherwise the record for this kind won't be emitted.
443   uint32_t NumValueSites;
444   // The first element of the array that stores the number of profiled
445   // values for each value site. The size of the array is NumValueSites.
446   // Since NumValueSites is greater than zero, there is at least one
447   // element in the array.
448   uint8_t SiteCountArray[1];
449
450   // The fake declaration is for documentation purpose only.
451   // Align the start of next field to be on 8 byte boundaries.
452   // uint8_t Padding[X];
453
454   // The array of value profile data. The size of the array is the sum
455   // of all elements in SiteCountArray[].
456   // InstrProfValueData ValueData[];
457
458   /// Return the \c ValueProfRecord header size including the padding bytes.
459   static uint32_t getHeaderSize(uint32_t NumValueSites);
460   /// Return the total size of the value profile record including the
461   /// header and the value data.
462   static uint32_t getSize(uint32_t NumValueSites, uint32_t NumValueData);
463   /// Return the total size of the value profile record including the
464   /// header and the value data.
465   uint32_t getSize() const { return getSize(NumValueSites, getNumValueData()); }
466   /// Use this method to advance to the next \c ValueProfRecord.
467   ValueProfRecord *getNext();
468   /// Return the pointer to the first value profile data.
469   InstrProfValueData *getValueData();
470   /// Return the number of value sites.
471   uint32_t getNumValueSites() const { return NumValueSites; }
472   /// Return the number of value data.
473   uint32_t getNumValueData() const;
474   /// Read data from this record and save it to Record.
475   void deserializeTo(InstrProfRecord &Record,
476                      InstrProfRecord::ValueMapType *VMap);
477   /// Extract data from \c Record and serialize into this instance.
478   void serializeFrom(const InstrProfRecord &Record, uint32_t ValueKind,
479                      uint32_t NumValueSites);
480   /// In-place byte swap:
481   /// Do byte swap for this instance. \c Old is the original order before
482   /// the swap, and \c New is the New byte order.
483   void swapBytes(support::endianness Old, support::endianness New);
484 };
485
486 /// Per-function header/control data structure for value profiling
487 /// data in indexed format.
488 struct ValueProfData {
489   // Total size in bytes including this field. It must be a multiple
490   // of sizeof(uint64_t).
491   uint32_t TotalSize;
492   // The number of value profile kinds that has value profile data.
493   // In this implementation, a value profile kind is considered to
494   // have profile data if the number of value profile sites for the
495   // kind is not zero. More aggressively, the implementation can
496   // choose to check the actual data value: if none of the value sites
497   // has any profiled values, the kind can be skipped.
498   uint32_t NumValueKinds;
499
500   // Following are a sequence of variable length records. The prefix/header
501   // of each record is defined by ValueProfRecord type. The number of
502   // records is NumValueKinds.
503   // ValueProfRecord Record_1;
504   // ValueProfRecord Record_N;
505
506   /// Return the total size in bytes of the on-disk value profile data
507   /// given the data stored in Record.
508   static uint32_t getSize(const InstrProfRecord &Record);
509   /// Return a pointer to \c ValueProfData instance ready to be streamed.
510   static std::unique_ptr<ValueProfData>
511   serializeFrom(const InstrProfRecord &Record);
512   /// Return a pointer to \c ValueProfileData instance ready to be read.
513   /// All data in the instance are properly byte swapped. The input
514   /// data is assumed to be in little endian order.
515   static ErrorOr<std::unique_ptr<ValueProfData>>
516   getValueProfData(const unsigned char *D, const unsigned char *const BufferEnd,
517                    support::endianness SrcDataEndianness);
518   /// Swap byte order from \c Endianness order to host byte order.
519   void swapBytesToHost(support::endianness Endianness);
520   /// Swap byte order from host byte order to \c Endianness order.
521   void swapBytesFromHost(support::endianness Endianness);
522   /// Return the total size of \c ValueProfileData.
523   uint32_t getSize() const { return TotalSize; }
524   /// Read data from this data and save it to \c Record.
525   void deserializeTo(InstrProfRecord &Record,
526                      InstrProfRecord::ValueMapType *VMap);
527   /// Return the first \c ValueProfRecord instance.
528   ValueProfRecord *getFirstValueProfRecord();
529 };
530
531 namespace IndexedInstrProf {
532
533 enum class HashT : uint32_t {
534   MD5,
535
536   Last = MD5
537 };
538
539 static inline uint64_t MD5Hash(StringRef Str) {
540   MD5 Hash;
541   Hash.update(Str);
542   llvm::MD5::MD5Result Result;
543   Hash.final(Result);
544   // Return the least significant 8 bytes. Our MD5 implementation returns the
545   // result in little endian, so we may need to swap bytes.
546   using namespace llvm::support;
547   return endian::read<uint64_t, little, unaligned>(Result);
548 }
549
550 static inline uint64_t ComputeHash(HashT Type, StringRef K) {
551   switch (Type) {
552   case HashT::MD5:
553     return IndexedInstrProf::MD5Hash(K);
554   }
555   llvm_unreachable("Unhandled hash type");
556 }
557
558 const uint64_t Magic = 0x8169666f72706cff; // "\xfflprofi\x81"
559 const uint64_t Version = 3;
560 const HashT HashType = HashT::MD5;
561
562 // This structure defines the file header of the LLVM profile
563 // data file in indexed-format.
564 struct Header {
565   uint64_t Magic;
566   uint64_t Version;
567   uint64_t MaxFunctionCount;
568   uint64_t HashType;
569   uint64_t HashOffset;
570 };
571
572 } // end namespace IndexedInstrProf
573
574 namespace RawInstrProf {
575
576 const uint64_t Version = INSTR_PROF_RAW_VERSION;
577
578 template <class IntPtrT> inline uint64_t getMagic();
579 template <> inline uint64_t getMagic<uint64_t>() {
580   return INSTR_PROF_RAW_MAGIC_64;
581 }
582
583 template <> inline uint64_t getMagic<uint32_t>() {
584   return INSTR_PROF_RAW_MAGIC_32;
585 }
586
587 // Per-function profile data header/control structure.
588 // The definition should match the structure defined in
589 // compiler-rt/lib/profile/InstrProfiling.h.
590 // It should also match the synthesized type in
591 // Transforms/Instrumentation/InstrProfiling.cpp:getOrCreateRegionCounters.
592 template <class IntPtrT> struct LLVM_ALIGNAS(8) ProfileData {
593   #define INSTR_PROF_DATA(Type, LLVMType, Name, Init) Type Name;
594   #include "llvm/ProfileData/InstrProfData.inc"
595 };
596
597 // File header structure of the LLVM profile data in raw format.
598 // The definition should match the header referenced in
599 // compiler-rt/lib/profile/InstrProfilingFile.c  and
600 // InstrProfilingBuffer.c.
601 struct Header {
602 #define INSTR_PROF_RAW_HEADER(Type, Name, Init) const Type Name;
603 #include "llvm/ProfileData/InstrProfData.inc"
604 };
605
606 }  // end namespace RawInstrProf
607
608 namespace coverage {
609
610 // Profile coverage map has the following layout:
611 // [CoverageMapFileHeader]
612 // [ArrayStart]
613 //  [CovMapFunctionRecord]
614 //  [CovMapFunctionRecord]
615 //  ...
616 // [ArrayEnd]
617 // [Encoded Region Mapping Data]
618 LLVM_PACKED_START
619 template <class IntPtrT> struct CovMapFunctionRecord {
620   #define COVMAP_FUNC_RECORD(Type, LLVMType, Name, Init) Type Name;
621   #include "llvm/ProfileData/InstrProfData.inc"
622 };
623 LLVM_PACKED_END
624
625 }
626
627 } // end namespace llvm
628
629 namespace std {
630 template <>
631 struct is_error_code_enum<llvm::instrprof_error> : std::true_type {};
632 }
633
634 #endif // LLVM_PROFILEDATA_INSTRPROF_H_