1 /*===-- InstrProfData.inc - instr profiling runtime structures -*- 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 is the master file that defines all the data structure, signature,
11 * constant literals that are shared across profiling runtime library,
12 * compiler (instrumentation), and host tools (reader/writer). The entities
13 * defined in this file affect the profile runtime ABI, the raw profile format,
16 * The file has two identical copies. The master copy lives in LLVM and
17 * the other one sits in compiler-rt/lib/profile directory. To make changes
18 * in this file, first modify the master copy and copy it over to compiler-rt.
19 * Testing of any change in this file can start only after the two copies are
22 * The first part of the file includes macros that defines types, names, and
23 * initializers for the member fields of the core data structures. The field
24 * declarations for one structure is enabled by defining the field activation
25 * macro associated with that structure. Only one field activation record
26 * can be defined at one time and the rest definitions will be filtered out by
29 * Examples of how the template is used to instantiate structure definition:
30 * 1. To declare a structure:
33 * #define INSTR_PROF_DATA(Type, LLVMType, Name, Initializer) \
35 * #include "llvm/ProfileData/InstrProfData.inc"
38 * 2. To construct LLVM type arrays for the struct type:
40 * Type *DataTypes[] = {
41 * #define INSTR_PROF_DATA(Type, LLVMType, Name, Initializer) \
43 * #include "llvm/ProfileData/InstrProfData.inc"
46 * 4. To construct constant array for the initializers:
47 * #define INSTR_PROF_DATA(Type, LLVMType, Name, Initializer) \
49 * Constant *ConstantVals[] = {
50 * #include "llvm/ProfileData/InstrProfData.inc"
54 * The second part of the file includes definitions all other entities that
55 * are related to runtime ABI and format. When no field activation macro is
56 * defined, this file can be included to introduce the definitions.
58 \*===----------------------------------------------------------------------===*/
60 /* Functions marked with INSTR_PROF_VISIBILITY must have hidden visibility in
61 * the compiler runtime. */
62 #ifndef INSTR_PROF_VISIBILITY
63 #define INSTR_PROF_VISIBILITY
66 /* INSTR_PROF_DATA start. */
67 /* Definition of member fields of the per-function control structure. */
68 #ifndef INSTR_PROF_DATA
69 #define INSTR_PROF_DATA(Type, LLVMType, Name, Initializer)
71 #define INSTR_PROF_DATA_DEFINED
73 INSTR_PROF_DATA(const uint64_t, llvm::Type::getInt64Ty(Ctx), NameRef, \
74 ConstantInt::get(llvm::Type::getInt64Ty(Ctx), \
75 IndexedInstrProf::ComputeHash(getPGOFuncNameVarInitializer(Inc->getName()))))
76 INSTR_PROF_DATA(const uint64_t, llvm::Type::getInt64Ty(Ctx), FuncHash, \
77 ConstantInt::get(llvm::Type::getInt64Ty(Ctx), \
78 Inc->getHash()->getZExtValue()))
79 INSTR_PROF_DATA(const IntPtrT, llvm::Type::getInt64PtrTy(Ctx), CounterPtr, \
80 ConstantExpr::getBitCast(CounterPtr, \
81 llvm::Type::getInt64PtrTy(Ctx)))
82 /* This is used to map function pointers for the indirect call targets to
83 * function name hashes during the conversion from raw to merged profile
86 INSTR_PROF_DATA(const IntPtrT, llvm::Type::getInt8PtrTy(Ctx), FunctionPointer, \
88 INSTR_PROF_DATA(IntPtrT, llvm::Type::getInt8PtrTy(Ctx), Values, \
90 INSTR_PROF_DATA(const uint32_t, llvm::Type::getInt32Ty(Ctx), NumCounters, \
91 ConstantInt::get(llvm::Type::getInt32Ty(Ctx), NumCounters))
92 INSTR_PROF_DATA(const uint16_t, Int16ArrayTy, NumValueSites[IPVK_Last+1], \
93 ConstantArray::get(Int16ArrayTy, Int16ArrayVals))
94 #undef INSTR_PROF_DATA
95 /* INSTR_PROF_DATA end. */
98 /* This is an internal data structure used by value profiler. It
99 * is defined here to allow serialization code sharing by LLVM
100 * to be used in unit test.
102 * typedef struct ValueProfNode {
103 * // InstrProfValueData VData;
106 * struct ValueProfNode *Next;
109 /* INSTR_PROF_VALUE_NODE start. */
110 #ifndef INSTR_PROF_VALUE_NODE
111 #define INSTR_PROF_VALUE_NODE(Type, LLVMType, Name, Initializer)
113 #define INSTR_PROF_DATA_DEFINED
115 INSTR_PROF_VALUE_NODE(uint64_t, llvm::Type::getInt64Ty(Ctx), Value, \
116 ConstantInt::get(llvm::Type::GetInt64Ty(Ctx), 0))
117 INSTR_PROF_VALUE_NODE(uint64_t, llvm::Type::getInt64Ty(Ctx), Count, \
118 ConstantInt::get(llvm::Type::GetInt64Ty(Ctx), 0))
119 INSTR_PROF_VALUE_NODE(PtrToNodeT, llvm::Type::getInt8PtrTy(Ctx), Next, \
120 ConstantInt::get(llvm::Type::GetInt8PtrTy(Ctx), 0))
121 #undef INSTR_PROF_VALUE_NODE
122 /* INSTR_PROF_VALUE_NODE end. */
124 /* INSTR_PROF_RAW_HEADER start */
125 /* Definition of member fields of the raw profile header data structure. */
126 #ifndef INSTR_PROF_RAW_HEADER
127 #define INSTR_PROF_RAW_HEADER(Type, Name, Initializer)
129 #define INSTR_PROF_DATA_DEFINED
131 INSTR_PROF_RAW_HEADER(uint64_t, Magic, __llvm_profile_get_magic())
132 INSTR_PROF_RAW_HEADER(uint64_t, Version, __llvm_profile_get_version())
133 INSTR_PROF_RAW_HEADER(uint64_t, DataSize, DataSize)
134 INSTR_PROF_RAW_HEADER(uint64_t, CountersSize, CountersSize)
135 INSTR_PROF_RAW_HEADER(uint64_t, NamesSize, NamesSize)
136 INSTR_PROF_RAW_HEADER(uint64_t, CountersDelta, (uintptr_t)CountersBegin)
137 INSTR_PROF_RAW_HEADER(uint64_t, NamesDelta, (uintptr_t)NamesBegin)
138 INSTR_PROF_RAW_HEADER(uint64_t, ValueKindLast, IPVK_Last)
139 #undef INSTR_PROF_RAW_HEADER
140 /* INSTR_PROF_RAW_HEADER end */
142 /* VALUE_PROF_FUNC_PARAM start */
143 /* Definition of parameter types of the runtime API used to do value profiling
144 * for a given value site.
146 #ifndef VALUE_PROF_FUNC_PARAM
147 #define VALUE_PROF_FUNC_PARAM(ArgType, ArgName, ArgLLVMType)
148 #define INSTR_PROF_COMMA
150 #define INSTR_PROF_DATA_DEFINED
151 #define INSTR_PROF_COMMA ,
153 VALUE_PROF_FUNC_PARAM(uint64_t, TargetValue, Type::getInt64Ty(Ctx)) \
155 VALUE_PROF_FUNC_PARAM(void *, Data, Type::getInt8PtrTy(Ctx)) INSTR_PROF_COMMA
156 VALUE_PROF_FUNC_PARAM(uint32_t, CounterIndex, Type::getInt32Ty(Ctx))
157 #undef VALUE_PROF_FUNC_PARAM
158 #undef INSTR_PROF_COMMA
159 /* VALUE_PROF_FUNC_PARAM end */
161 /* VALUE_PROF_KIND start */
162 #ifndef VALUE_PROF_KIND
163 #define VALUE_PROF_KIND(Enumerator, Value)
165 #define INSTR_PROF_DATA_DEFINED
167 /* For indirect function call value profiling, the addresses of the target
168 * functions are profiled by the instrumented code. The target addresses are
169 * written in the raw profile data and converted to target function name's MD5
170 * hash by the profile reader during deserialization. Typically, this happens
171 * when the the raw profile data is read during profile merging.
173 * For this remapping the ProfData is used. ProfData contains both the function
174 * name hash and the function address.
176 VALUE_PROF_KIND(IPVK_IndirectCallTarget, 0)
177 /* These two kinds must be the last to be
178 * declared. This is to make sure the string
179 * array created with the template can be
180 * indexed with the kind value.
182 VALUE_PROF_KIND(IPVK_First, IPVK_IndirectCallTarget)
183 VALUE_PROF_KIND(IPVK_Last, IPVK_IndirectCallTarget)
185 #undef VALUE_PROF_KIND
186 /* VALUE_PROF_KIND end */
188 /* COVMAP_FUNC_RECORD start */
189 /* Definition of member fields of the function record structure in coverage
192 #ifndef COVMAP_FUNC_RECORD
193 #define COVMAP_FUNC_RECORD(Type, LLVMType, Name, Initializer)
195 #define INSTR_PROF_DATA_DEFINED
198 COVMAP_FUNC_RECORD(const IntPtrT, llvm::Type::getInt8PtrTy(Ctx), \
199 NamePtr, llvm::ConstantExpr::getBitCast(NamePtr, \
200 llvm::Type::getInt8PtrTy(Ctx)))
201 COVMAP_FUNC_RECORD(const uint32_t, llvm::Type::getInt32Ty(Ctx), NameSize, \
202 llvm::ConstantInt::get(llvm::Type::getInt32Ty(Ctx), \
205 COVMAP_FUNC_RECORD(const int64_t, llvm::Type::getInt64Ty(Ctx), NameRef, \
206 llvm::ConstantInt::get(llvm::Type::getInt64Ty(Ctx), \
207 llvm::IndexedInstrProf::ComputeHash(NameValue)))
209 COVMAP_FUNC_RECORD(const uint32_t, llvm::Type::getInt32Ty(Ctx), DataSize, \
210 llvm::ConstantInt::get(llvm::Type::getInt32Ty(Ctx),\
211 CoverageMapping.size()))
212 COVMAP_FUNC_RECORD(const uint64_t, llvm::Type::getInt64Ty(Ctx), FuncHash, \
213 llvm::ConstantInt::get(llvm::Type::getInt64Ty(Ctx), FuncHash))
214 #undef COVMAP_FUNC_RECORD
215 /* COVMAP_FUNC_RECORD end. */
217 /* COVMAP_HEADER start */
218 /* Definition of member fields of coverage map header.
220 #ifndef COVMAP_HEADER
221 #define COVMAP_HEADER(Type, LLVMType, Name, Initializer)
223 #define INSTR_PROF_DATA_DEFINED
225 COVMAP_HEADER(uint32_t, Int32Ty, NRecords, \
226 llvm::ConstantInt::get(Int32Ty, FunctionRecords.size()))
227 COVMAP_HEADER(uint32_t, Int32Ty, FilenamesSize, \
228 llvm::ConstantInt::get(Int32Ty, FilenamesSize))
229 COVMAP_HEADER(uint32_t, Int32Ty, CoverageSize, \
230 llvm::ConstantInt::get(Int32Ty, CoverageMappingSize))
231 COVMAP_HEADER(uint32_t, Int32Ty, Version, \
232 llvm::ConstantInt::get(Int32Ty, CovMapVersion::CurrentVersion))
234 /* COVMAP_HEADER end. */
237 #ifdef INSTR_PROF_VALUE_PROF_DATA
238 #define INSTR_PROF_DATA_DEFINED
240 #define INSTR_PROF_MAX_NUM_VAL_PER_SITE 255
242 * This is the header of the data structure that defines the on-disk
243 * layout of the value profile data of a particular kind for one function.
245 typedef struct ValueProfRecord {
246 /* The kind of the value profile record. */
249 * The number of value profile sites. It is guaranteed to be non-zero;
250 * otherwise the record for this kind won't be emitted.
252 uint32_t NumValueSites;
254 * The first element of the array that stores the number of profiled
255 * values for each value site. The size of the array is NumValueSites.
256 * Since NumValueSites is greater than zero, there is at least one
257 * element in the array.
259 uint8_t SiteCountArray[1];
262 * The fake declaration is for documentation purpose only.
263 * Align the start of next field to be on 8 byte boundaries.
267 /* The array of value profile data. The size of the array is the sum
268 * of all elements in SiteCountArray[].
269 InstrProfValueData ValueData[];
274 * \brief Return the number of value sites.
276 uint32_t getNumValueSites() const { return NumValueSites; }
278 * \brief Read data from this record and save it to Record.
280 void deserializeTo(InstrProfRecord &Record,
281 InstrProfRecord::ValueMapType *VMap);
283 * In-place byte swap:
284 * Do byte swap for this instance. \c Old is the original order before
285 * the swap, and \c New is the New byte order.
287 void swapBytes(support::endianness Old, support::endianness New);
292 * Per-function header/control data structure for value profiling
293 * data in indexed format.
295 typedef struct ValueProfData {
297 * Total size in bytes including this field. It must be a multiple
298 * of sizeof(uint64_t).
302 *The number of value profile kinds that has value profile data.
303 * In this implementation, a value profile kind is considered to
304 * have profile data if the number of value profile sites for the
305 * kind is not zero. More aggressively, the implementation can
306 * choose to check the actual data value: if none of the value sites
307 * has any profiled values, the kind can be skipped.
309 uint32_t NumValueKinds;
312 * Following are a sequence of variable length records. The prefix/header
313 * of each record is defined by ValueProfRecord type. The number of
314 * records is NumValueKinds.
315 * ValueProfRecord Record_1;
316 * ValueProfRecord Record_N;
321 * Return the total size in bytes of the on-disk value profile data
322 * given the data stored in Record.
324 static uint32_t getSize(const InstrProfRecord &Record);
326 * Return a pointer to \c ValueProfData instance ready to be streamed.
328 static std::unique_ptr<ValueProfData>
329 serializeFrom(const InstrProfRecord &Record);
331 * Check the integrity of the record.
333 Error checkIntegrity();
335 * Return a pointer to \c ValueProfileData instance ready to be read.
336 * All data in the instance are properly byte swapped. The input
337 * data is assumed to be in little endian order.
339 static Expected<std::unique_ptr<ValueProfData>>
340 getValueProfData(const unsigned char *SrcBuffer,
341 const unsigned char *const SrcBufferEnd,
342 support::endianness SrcDataEndianness);
344 * Swap byte order from \c Endianness order to host byte order.
346 void swapBytesToHost(support::endianness Endianness);
348 * Swap byte order from host byte order to \c Endianness order.
350 void swapBytesFromHost(support::endianness Endianness);
352 * Return the total size of \c ValueProfileData.
354 uint32_t getSize() const { return TotalSize; }
356 * Read data from this data and save it to \c Record.
358 void deserializeTo(InstrProfRecord &Record,
359 InstrProfRecord::ValueMapType *VMap);
360 void operator delete(void *ptr) { ::operator delete(ptr); }
365 * The closure is designed to abstact away two types of value profile data:
366 * - InstrProfRecord which is the primary data structure used to
367 * represent profile data in host tools (reader, writer, and profile-use)
368 * - value profile runtime data structure suitable to be used by C
371 * Both sources of data need to serialize to disk/memory-buffer in common
372 * format: ValueProfData. The abstraction allows compiler-rt's raw profiler
373 * writer to share the same format and code with indexed profile writer.
375 * For documentation of the member methods below, refer to corresponding methods
376 * in class InstrProfRecord.
378 typedef struct ValueProfRecordClosure {
380 uint32_t (*GetNumValueKinds)(const void *Record);
381 uint32_t (*GetNumValueSites)(const void *Record, uint32_t VKind);
382 uint32_t (*GetNumValueData)(const void *Record, uint32_t VKind);
383 uint32_t (*GetNumValueDataForSite)(const void *R, uint32_t VK, uint32_t S);
386 * After extracting the value profile data from the value profile record,
387 * this method is used to map the in-memory value to on-disk value. If
388 * the method is null, value will be written out untranslated.
390 uint64_t (*RemapValueData)(uint32_t, uint64_t Value);
391 void (*GetValueForSite)(const void *R, InstrProfValueData *Dst, uint32_t K,
393 ValueProfData *(*AllocValueProfData)(size_t TotalSizeInBytes);
394 } ValueProfRecordClosure;
396 INSTR_PROF_VISIBILITY ValueProfRecord *
397 getFirstValueProfRecord(ValueProfData *VPD);
398 INSTR_PROF_VISIBILITY ValueProfRecord *
399 getValueProfRecordNext(ValueProfRecord *VPR);
400 INSTR_PROF_VISIBILITY InstrProfValueData *
401 getValueProfRecordValueData(ValueProfRecord *VPR);
402 INSTR_PROF_VISIBILITY uint32_t
403 getValueProfRecordHeaderSize(uint32_t NumValueSites);
405 #undef INSTR_PROF_VALUE_PROF_DATA
406 #endif /* INSTR_PROF_VALUE_PROF_DATA */
409 #ifdef INSTR_PROF_COMMON_API_IMPL
410 #define INSTR_PROF_DATA_DEFINED
412 #define INSTR_PROF_INLINE inline
413 #define INSTR_PROF_NULLPTR nullptr
415 #define INSTR_PROF_INLINE
416 #define INSTR_PROF_NULLPTR NULL
420 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
424 * \brief Return the \c ValueProfRecord header size including the
427 INSTR_PROF_VISIBILITY INSTR_PROF_INLINE
428 uint32_t getValueProfRecordHeaderSize(uint32_t NumValueSites) {
429 uint32_t Size = offsetof(ValueProfRecord, SiteCountArray) +
430 sizeof(uint8_t) * NumValueSites;
431 /* Round the size to multiple of 8 bytes. */
432 Size = (Size + 7) & ~7;
437 * \brief Return the total size of the value profile record including the
438 * header and the value data.
440 INSTR_PROF_VISIBILITY INSTR_PROF_INLINE
441 uint32_t getValueProfRecordSize(uint32_t NumValueSites,
442 uint32_t NumValueData) {
443 return getValueProfRecordHeaderSize(NumValueSites) +
444 sizeof(InstrProfValueData) * NumValueData;
448 * \brief Return the pointer to the start of value data array.
450 INSTR_PROF_VISIBILITY INSTR_PROF_INLINE
451 InstrProfValueData *getValueProfRecordValueData(ValueProfRecord *This) {
452 return (InstrProfValueData *)((char *)This + getValueProfRecordHeaderSize(
453 This->NumValueSites));
457 * \brief Return the total number of value data for \c This record.
459 INSTR_PROF_VISIBILITY INSTR_PROF_INLINE
460 uint32_t getValueProfRecordNumValueData(ValueProfRecord *This) {
461 uint32_t NumValueData = 0;
463 for (I = 0; I < This->NumValueSites; I++)
464 NumValueData += This->SiteCountArray[I];
469 * \brief Use this method to advance to the next \c This \c ValueProfRecord.
471 INSTR_PROF_VISIBILITY INSTR_PROF_INLINE
472 ValueProfRecord *getValueProfRecordNext(ValueProfRecord *This) {
473 uint32_t NumValueData = getValueProfRecordNumValueData(This);
474 return (ValueProfRecord *)((char *)This +
475 getValueProfRecordSize(This->NumValueSites,
480 * \brief Return the first \c ValueProfRecord instance.
482 INSTR_PROF_VISIBILITY INSTR_PROF_INLINE
483 ValueProfRecord *getFirstValueProfRecord(ValueProfData *This) {
484 return (ValueProfRecord *)((char *)This + sizeof(ValueProfData));
487 /* Closure based interfaces. */
490 * Return the total size in bytes of the on-disk value profile data
491 * given the data stored in Record.
493 INSTR_PROF_VISIBILITY uint32_t
494 getValueProfDataSize(ValueProfRecordClosure *Closure) {
496 uint32_t TotalSize = sizeof(ValueProfData);
497 const void *Record = Closure->Record;
499 for (Kind = IPVK_First; Kind <= IPVK_Last; Kind++) {
500 uint32_t NumValueSites = Closure->GetNumValueSites(Record, Kind);
503 TotalSize += getValueProfRecordSize(NumValueSites,
504 Closure->GetNumValueData(Record, Kind));
510 * Extract value profile data of a function for the profile kind \c ValueKind
511 * from the \c Closure and serialize the data into \c This record instance.
513 INSTR_PROF_VISIBILITY void
514 serializeValueProfRecordFrom(ValueProfRecord *This,
515 ValueProfRecordClosure *Closure,
516 uint32_t ValueKind, uint32_t NumValueSites) {
518 const void *Record = Closure->Record;
519 This->Kind = ValueKind;
520 This->NumValueSites = NumValueSites;
521 InstrProfValueData *DstVD = getValueProfRecordValueData(This);
523 for (S = 0; S < NumValueSites; S++) {
524 uint32_t ND = Closure->GetNumValueDataForSite(Record, ValueKind, S);
525 This->SiteCountArray[S] = ND;
526 Closure->GetValueForSite(Record, DstVD, ValueKind, S);
532 * Extract value profile data of a function from the \c Closure
533 * and serialize the data into \c DstData if it is not NULL or heap
534 * memory allocated by the \c Closure's allocator method. If \c
535 * DstData is not null, the caller is expected to set the TotalSize
538 INSTR_PROF_VISIBILITY ValueProfData *
539 serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
540 ValueProfData *DstData) {
543 DstData ? DstData->TotalSize : getValueProfDataSize(Closure);
546 DstData ? DstData : Closure->AllocValueProfData(TotalSize);
548 VPD->TotalSize = TotalSize;
549 VPD->NumValueKinds = Closure->GetNumValueKinds(Closure->Record);
550 ValueProfRecord *VR = getFirstValueProfRecord(VPD);
551 for (Kind = IPVK_First; Kind <= IPVK_Last; Kind++) {
552 uint32_t NumValueSites = Closure->GetNumValueSites(Closure->Record, Kind);
555 serializeValueProfRecordFrom(VR, Closure, Kind, NumValueSites);
556 VR = getValueProfRecordNext(VR);
561 #undef INSTR_PROF_COMMON_API_IMPL
562 #endif /* INSTR_PROF_COMMON_API_IMPL */
564 /*============================================================================*/
566 #ifndef INSTR_PROF_DATA_DEFINED
568 #ifndef INSTR_PROF_DATA_INC
569 #define INSTR_PROF_DATA_INC
572 #define INSTR_PROF_SIMPLE_QUOTE(x) #x
573 #define INSTR_PROF_QUOTE(x) INSTR_PROF_SIMPLE_QUOTE(x)
574 #define INSTR_PROF_SIMPLE_CONCAT(x,y) x ## y
575 #define INSTR_PROF_CONCAT(x,y) INSTR_PROF_SIMPLE_CONCAT(x,y)
577 /* Magic number to detect file format and endianness.
578 * Use 255 at one end, since no UTF-8 file can use that character. Avoid 0,
579 * so that utilities, like strings, don't grab it as a string. 129 is also
580 * invalid UTF-8, and high enough to be interesting.
581 * Use "lprofr" in the centre to stand for "LLVM Profile Raw", or "lprofR"
582 * for 32-bit platforms.
584 #define INSTR_PROF_RAW_MAGIC_64 (uint64_t)255 << 56 | (uint64_t)'l' << 48 | \
585 (uint64_t)'p' << 40 | (uint64_t)'r' << 32 | (uint64_t)'o' << 24 | \
586 (uint64_t)'f' << 16 | (uint64_t)'r' << 8 | (uint64_t)129
587 #define INSTR_PROF_RAW_MAGIC_32 (uint64_t)255 << 56 | (uint64_t)'l' << 48 | \
588 (uint64_t)'p' << 40 | (uint64_t)'r' << 32 | (uint64_t)'o' << 24 | \
589 (uint64_t)'f' << 16 | (uint64_t)'R' << 8 | (uint64_t)129
591 /* Raw profile format version (start from 1). */
592 #define INSTR_PROF_RAW_VERSION 4
593 /* Indexed profile format version (start from 1). */
594 #define INSTR_PROF_INDEX_VERSION 4
595 /* Coverage mapping format vresion (start from 0). */
596 #define INSTR_PROF_COVMAP_VERSION 1
598 /* Profile version is always of type uint64_t. Reserve the upper 8 bits in the
599 * version for other variants of profile. We set the lowest bit of the upper 8
600 * bits (i.e. bit 56) to 1 to indicate if this is an IR-level instrumentaiton
601 * generated profile, and 0 if this is a Clang FE generated profile.
603 #define VARIANT_MASKS_ALL 0xff00000000000000ULL
604 #define GET_VERSION(V) ((V) & ~VARIANT_MASKS_ALL)
605 #define VARIANT_MASK_IR_PROF (0x1ULL << 56)
606 #define IR_LEVEL_PROF_VERSION_VAR __llvm_profile_raw_version
608 /* Runtime section names and name strings. */
609 #define INSTR_PROF_DATA_SECT_NAME __llvm_prf_data
610 #define INSTR_PROF_NAME_SECT_NAME __llvm_prf_names
611 #define INSTR_PROF_CNTS_SECT_NAME __llvm_prf_cnts
612 /* Array of pointers. Each pointer points to a list
613 * of value nodes associated with one value site.
615 #define INSTR_PROF_VALS_SECT_NAME __llvm_prf_vals
616 /* Value profile nodes section. */
617 #define INSTR_PROF_VNODES_SECT_NAME __llvm_prf_vnds
618 #define INSTR_PROF_COVMAP_SECT_NAME __llvm_covmap
620 #define INSTR_PROF_DATA_SECT_NAME_STR \
621 INSTR_PROF_QUOTE(INSTR_PROF_DATA_SECT_NAME)
622 #define INSTR_PROF_NAME_SECT_NAME_STR \
623 INSTR_PROF_QUOTE(INSTR_PROF_NAME_SECT_NAME)
624 #define INSTR_PROF_CNTS_SECT_NAME_STR \
625 INSTR_PROF_QUOTE(INSTR_PROF_CNTS_SECT_NAME)
626 #define INSTR_PROF_COVMAP_SECT_NAME_STR \
627 INSTR_PROF_QUOTE(INSTR_PROF_COVMAP_SECT_NAME)
628 #define INSTR_PROF_VALS_SECT_NAME_STR \
629 INSTR_PROF_QUOTE(INSTR_PROF_VALS_SECT_NAME)
630 #define INSTR_PROF_VNODES_SECT_NAME_STR \
631 INSTR_PROF_QUOTE(INSTR_PROF_VNODES_SECT_NAME)
633 /* Macros to define start/stop section symbol for a given
634 * section on Linux. For instance
635 * INSTR_PROF_SECT_START(INSTR_PROF_DATA_SECT_NAME) will
636 * expand to __start___llvm_prof_data
638 #define INSTR_PROF_SECT_START(Sect) \
639 INSTR_PROF_CONCAT(__start_,Sect)
640 #define INSTR_PROF_SECT_STOP(Sect) \
641 INSTR_PROF_CONCAT(__stop_,Sect)
643 /* Value Profiling API linkage name. */
644 #define INSTR_PROF_VALUE_PROF_FUNC __llvm_profile_instrument_target
645 #define INSTR_PROF_VALUE_PROF_FUNC_STR \
646 INSTR_PROF_QUOTE(INSTR_PROF_VALUE_PROF_FUNC)
648 /* InstrProfile per-function control data alignment. */
649 #define INSTR_PROF_DATA_ALIGNMENT 8
651 /* The data structure that represents a tracked value by the
654 typedef struct InstrProfValueData {
655 /* Profiled value. */
657 /* Number of times the value appears in the training run. */
659 } InstrProfValueData;
661 #endif /* INSTR_PROF_DATA_INC */
664 #undef INSTR_PROF_DATA_DEFINED