1 //===-- InstrProfData.inc - instr profiling runtime structures-----===//
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 defines templates for core runtime data structures used by
11 // instrumentation based profiling and coverage mapping. The instrumentation
12 // runtime library, the compiler IR lowering, and profile reader/writer need
13 // to use the same template to make sure the same data structure is defined
16 // Examples of how the template is used:
17 // 1. To declare a structure:
20 // #define INSTR_PROF_DATA(Type, LLVMType, Name, Initializer) \
22 // #include "llvm/ProfileData/InstrProfData.inc"
25 // 2. To construct LLVM type arrays for the struct type:
27 // Type *DataTypes[] = {
28 // #define INSTR_PROF_DATA(Type, LLVMType, Name, Initializer) \
30 // #include "llvm/ProfileData/InstrProfData.inc"
33 // 4. To construct constant array for the initializers:
34 // #define INSTR_PROF_DATA(Type, LLVMType, Name, Initializer) \
36 // Constant *ConstantVals[] = {
37 // #include "llvm/ProfileData/InstrProfData.inc"
39 //===----------------------------------------------------------------------===//
41 /* INSTR_PROF_DATA start. */
42 /* Definition of member fields of the per-function control structure. */
43 #ifndef INSTR_PROF_DATA
44 #define INSTR_PROF_DATA(Type, LLVMType, Name, Initializer)
46 #define INSTR_PROF_DATA_DEFINED
49 INSTR_PROF_DATA(const uint32_t, llvm::Type::getInt32Ty(Ctx), NameSize, \
50 ConstantInt::get(llvm::Type::getInt32Ty(Ctx), \
51 NamePtr->getType()->getPointerElementType()->getArrayNumElements()))
52 INSTR_PROF_DATA(const uint32_t, llvm::Type::getInt32Ty(Ctx), NumCounters, \
53 ConstantInt::get(llvm::Type::getInt32Ty(Ctx), NumCounters))
54 INSTR_PROF_DATA(const uint64_t, llvm::Type::getInt64Ty(Ctx), FuncHash, \
55 ConstantInt::get(llvm::Type::getInt64Ty(Ctx), \
56 Inc->getHash()->getZExtValue()))
57 INSTR_PROF_DATA(const IntPtrT, llvm::Type::getInt8PtrTy(Ctx), NamePtr, \
58 ConstantExpr::getBitCast(NamePtr, llvm::Type::getInt8PtrTy(Ctx)))
59 INSTR_PROF_DATA(const IntPtrT, llvm::Type::getInt64PtrTy(Ctx), CounterPtr, \
60 ConstantExpr::getBitCast(CounterPtr, \
61 llvm::Type::getInt64PtrTy(Ctx)))
62 INSTR_PROF_DATA(const IntPtrT, llvm::Type::getInt8PtrTy(Ctx), FunctionPointer, \
64 INSTR_PROF_DATA(IntPtrT, llvm::Type::getInt8PtrTy(Ctx), Values, \
65 ConstantPointerNull::get(Int8PtrTy))
66 INSTR_PROF_DATA(const uint16_t, Int16ArrayTy, NumValueSites[IPVK_Last+1], \
67 ConstantArray::get(Int16ArrayTy, Int16ArrayVals))
68 #undef INSTR_PROF_DATA
70 /* INSTR_PROF_DATA end. */
72 /* INSTR_PROF_RAW_HEADER start */
73 /* Definition of member fields of the raw profile header data structure. */
74 #ifndef INSTR_PROF_RAW_HEADER
75 #define INSTR_PROF_RAW_HEADER(Type, Name, Initializer)
77 #define INSTR_PROF_DATA_DEFINED
79 INSTR_PROF_RAW_HEADER(const uint64_t, Magic, __llvm_profile_get_magic())
80 INSTR_PROF_RAW_HEADER(const uint64_t, Version, __llvm_profile_get_version())
81 INSTR_PROF_RAW_HEADER(const uint64_t, DataSize, DataSize)
82 INSTR_PROF_RAW_HEADER(const uint64_t, CountersSize, CountersSize)
83 INSTR_PROF_RAW_HEADER(const uint64_t, NamesSize, NameSize)
84 INSTR_PROF_RAW_HEADER(const uint64_t, CountersDelta, (uintptr_t)CountersBegin)
85 INSTR_PROF_RAW_HEADER(const uint64_t, NamesDelta, (uintptr_t)NamesBegin)
86 INSTR_PROF_RAW_HEADER(const uint64_t, ValueKindLast, IPVK_Last)
87 INSTR_PROF_RAW_HEADER(const uint64_t, ValueDataSize, ValueDataSize)
88 INSTR_PROF_RAW_HEADER(const uint64_t, ValueDataDelta, (uintptr_t)ValueDataBegin)
89 #undef INSTR_PROF_RAW_HEADER
90 /* INSTR_PROF_RAW_HEADER end */
93 /* COVMAP_FUNC_RECORD start */
94 /* Definition of member fields of the function record structure in coverage
97 #ifndef COVMAP_FUNC_RECORD
98 #define COVMAP_FUNC_RECORD(Type, LLVMType, Name, Initializer)
100 #define INSTR_PROF_DATA_DEFINED
102 COVMAP_FUNC_RECORD(const IntPtrT, llvm::Type::getInt8PtrTy(Ctx), \
103 NamePtr, llvm::ConstantExpr::getBitCast(NamePtr, \
104 llvm::Type::getInt8PtrTy(Ctx)))
105 COVMAP_FUNC_RECORD(const uint32_t, llvm::Type::getInt32Ty(Ctx), NameSize, \
106 llvm::ConstantInt::get(llvm::Type::getInt32Ty(Ctx),\
108 COVMAP_FUNC_RECORD(const uint32_t, llvm::Type::getInt32Ty(Ctx), DataSize, \
109 llvm::ConstantInt::get(llvm::Type::getInt32Ty(Ctx),\
110 CoverageMapping.size()))
111 COVMAP_FUNC_RECORD(const uint64_t, llvm::Type::getInt64Ty(Ctx), FuncHash, \
112 llvm::ConstantInt::get(llvm::Type::getInt64Ty(Ctx), FuncHash))
113 #undef COVMAP_FUNC_RECORD
114 /* COVMAP_FUNC_RECORD end. */