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 #ifndef INSTR_PROF_DATA
42 #define INSTR_PROF_DATA(Type, LLVMType, Name, Initializer)
45 // INSTR_PROF_DATA_START
46 INSTR_PROF_DATA(const uint32_t, llvm::Type::getInt32Ty(Ctx), NameSize, \
47 ConstantInt::get(llvm::Type::getInt32Ty(Ctx), \
48 NamePtr->getType()->getPointerElementType()->getArrayNumElements()))
49 INSTR_PROF_DATA(const uint32_t, llvm::Type::getInt32Ty(Ctx), NumCounters, \
50 ConstantInt::get(llvm::Type::getInt32Ty(Ctx), NumCounters))
51 INSTR_PROF_DATA(const uint64_t, llvm::Type::getInt64Ty(Ctx), FuncHash, \
52 ConstantInt::get(llvm::Type::getInt64Ty(Ctx), \
53 Inc->getHash()->getZExtValue()))
54 INSTR_PROF_DATA(const IntPtrT, llvm::Type::getInt8PtrTy(Ctx), NamePtr, \
55 ConstantExpr::getBitCast(NamePtr, llvm::Type::getInt8PtrTy(Ctx)))
56 INSTR_PROF_DATA(const IntPtrT, llvm::Type::getInt64PtrTy(Ctx), CounterPtr, \
57 ConstantExpr::getBitCast(CounterPtr, \
58 llvm::Type::getInt64PtrTy(Ctx)))
59 // INSTR_PROF_DATA_END
61 #ifdef INSTR_PROF_DATA
62 #undef INSTR_PROF_DATA
66 #ifndef COVMAP_FUNC_RECORD
67 #define COVMAP_FUNC_RECORD(Type, LLVMType, Name, Initializer)
70 // COVMAP_FUNC_RECORD_START
71 COVMAP_FUNC_RECORD(const IntPtrT, llvm::Type::getInt8PtrTy(Ctx), \
72 NamePtr, llvm::ConstantExpr::getBitCast(NamePtr, \
73 llvm::Type::getInt8PtrTy(Ctx)))
74 COVMAP_FUNC_RECORD(const uint32_t, llvm::Type::getInt32Ty(Ctx), NameSize, \
75 llvm::ConstantInt::get(llvm::Type::getInt32Ty(Ctx),\
77 COVMAP_FUNC_RECORD(const uint32_t, llvm::Type::getInt32Ty(Ctx), DataSize, \
78 llvm::ConstantInt::get(llvm::Type::getInt32Ty(Ctx),\
79 CoverageMapping.size()))
80 COVMAP_FUNC_RECORD(const uint64_t, llvm::Type::getInt64Ty(Ctx), FuncHash, \
81 llvm::ConstantInt::get(llvm::Type::getInt64Ty(Ctx), FuncHash))
82 // COVMAP_FUNC_RECORD_END
84 #ifdef COVMAP_FUNC_RECORD
85 #undef COVMAP_FUNC_RECORD