// 1. To declare a structure:
//
// struct ProfData {
-// #define INSTR_PROF_DATA(Type, LLVMTypeVar, LLVMType, Name, Initializer) \
+// #define INSTR_PROF_DATA(Type, LLVMType, Name, Initializer) \
// Type Name;
-// #include "ProfileData/InstrProfData.inc"
+// #include "llvm/ProfileData/InstrProfData.inc"
// };
//
-// 2. To define local variables for struct member's LLVM types"
-//
-// #define INSTR_PROF_DATA(Type, LLVMTypeVar, LLVMType, Name, Initializer) \
-// LLVMTypeVar = LLVMType;
-// #include "ProfileData/InstrProfData.inc"
-//
-// 3. To construct LLVM type arrays for the struct type:
+// 2. To construct LLVM type arrays for the struct type:
//
// Type *DataTypes[] = {
-// #define INSTR_PROF_DATA(Type, LLVMTypeVar, LLVMType, Name, Initializer) \
-// LLVMTypeVar,
-// #include "ProfileData/InstrProfData.inc"
+// #define INSTR_PROF_DATA(Type, LLVMType, Name, Initializer) \
+// LLVMType,
+// #include "llvm/ProfileData/InstrProfData.inc"
// };
//
// 4. To construct constant array for the initializers:
-// #define INSTR_PROF_DATA(Type, LLVMTypeVar, LLVMType, Name, Initializer) \
+// #define INSTR_PROF_DATA(Type, LLVMType, Name, Initializer) \
// Initializer,
// Constant *ConstantVals[] = {
-// #include "ProfileData/InstrProfData.inc"
+// #include "llvm/ProfileData/InstrProfData.inc"
// };
//===----------------------------------------------------------------------===//
+/* INSTR_PROF_DATA start. */
+/* Definition of member fields of the per-function control structure. */
#ifndef INSTR_PROF_DATA
-#define INSTR_PROF_DATA(Type, LLVMTypeVar, LLVMType, Name, Initializer)
+#define INSTR_PROF_DATA(Type, LLVMType, Name, Initializer)
+#else
+#define INSTR_PROF_DATA_DEFINED
#endif
-// INSTR_PROF_DATA_START
-INSTR_PROF_DATA(const uint32_t, Int32Ty, llvm::Type::getInt32Ty(Ctx), NameSize, \
- ConstantInt::get(Int32Ty, NameSize))
-INSTR_PROF_DATA(const uint32_t, Int32Ty, llvm::Type::getInt32Ty(Ctx), NumCounters, \
- ConstantInt::get(Int32Ty, NumCounters))
-INSTR_PROF_DATA(const uint64_t, Int64Ty, llvm::Type::getInt64Ty(Ctx), FuncHash, \
- ConstantInt::get(Int64Ty, FuncHash))
-INSTR_PROF_DATA(const IntPtrT, Int8PtrTy,llvm::Type::getInt8PtrTy(Ctx), NamePtr, \
- ConstantExpr::getBitCast(Name, Int8PtrTy))
-INSTR_PROF_DATA(const IntPtrT, Int64PtrTy, llvm::Type::getInt64PtrTy(Ctx), CounterPtr, \
- ConstantExpr::getBitCast(CounterPtr, Int8PtrTy))
-// INSTR_PROF_DATA_END
-
-#ifdef INSTR_PROF_DATA
+INSTR_PROF_DATA(const uint32_t, llvm::Type::getInt32Ty(Ctx), NameSize, \
+ ConstantInt::get(llvm::Type::getInt32Ty(Ctx), \
+ NamePtr->getType()->getPointerElementType()->getArrayNumElements()))
+INSTR_PROF_DATA(const uint32_t, llvm::Type::getInt32Ty(Ctx), NumCounters, \
+ ConstantInt::get(llvm::Type::getInt32Ty(Ctx), NumCounters))
+INSTR_PROF_DATA(const uint64_t, llvm::Type::getInt64Ty(Ctx), FuncHash, \
+ ConstantInt::get(llvm::Type::getInt64Ty(Ctx), \
+ Inc->getHash()->getZExtValue()))
+INSTR_PROF_DATA(const IntPtrT, llvm::Type::getInt8PtrTy(Ctx), NamePtr, \
+ ConstantExpr::getBitCast(NamePtr, llvm::Type::getInt8PtrTy(Ctx)))
+INSTR_PROF_DATA(const IntPtrT, llvm::Type::getInt64PtrTy(Ctx), CounterPtr, \
+ ConstantExpr::getBitCast(CounterPtr, \
+ llvm::Type::getInt64PtrTy(Ctx)))
+INSTR_PROF_DATA(const IntPtrT, llvm::Type::getInt8PtrTy(Ctx), FunctionPointer, \
+ FunctionAddr)
+INSTR_PROF_DATA(IntPtrT, llvm::Type::getInt8PtrTy(Ctx), Values, \
+ ConstantPointerNull::get(Int8PtrTy))
+INSTR_PROF_DATA(const uint16_t, Int16ArrayTy, NumValueSites[IPVK_Last+1], \
+ ConstantArray::get(Int16ArrayTy, Int16ArrayVals))
#undef INSTR_PROF_DATA
+/* INSTR_PROF_DATA end. */
+
+/* INSTR_PROF_RAW_HEADER start */
+/* Definition of member fields of the raw profile header data structure. */
+#ifndef INSTR_PROF_RAW_HEADER
+#define INSTR_PROF_RAW_HEADER(Type, Name, Initializer)
+#else
+#define INSTR_PROF_DATA_DEFINED
#endif
+INSTR_PROF_RAW_HEADER(const uint64_t, Magic, __llvm_profile_get_magic())
+INSTR_PROF_RAW_HEADER(const uint64_t, Version, __llvm_profile_get_version())
+INSTR_PROF_RAW_HEADER(const uint64_t, DataSize, DataSize)
+INSTR_PROF_RAW_HEADER(const uint64_t, CountersSize, CountersSize)
+INSTR_PROF_RAW_HEADER(const uint64_t, NamesSize, NameSize)
+INSTR_PROF_RAW_HEADER(const uint64_t, CountersDelta, (uintptr_t)CountersBegin)
+INSTR_PROF_RAW_HEADER(const uint64_t, NamesDelta, (uintptr_t)NamesBegin)
+INSTR_PROF_RAW_HEADER(const uint64_t, ValueKindLast, IPVK_Last)
+INSTR_PROF_RAW_HEADER(const uint64_t, ValueDataSize, ValueDataSize)
+INSTR_PROF_RAW_HEADER(const uint64_t, ValueDataDelta, (uintptr_t)ValueDataBegin)
+#undef INSTR_PROF_RAW_HEADER
+/* INSTR_PROF_RAW_HEADER end */
+/* VALUE_PROF_FUNC_PARAM start */
+/* Definition of parameter types of the runtime API used to do value profiling
+ * for a given value site.
+ */
+#ifndef VALUE_PROF_FUNC_PARAM
+#define VALUE_PROF_FUNC_PARAM(ArgType, ArgName, ArgLLVMType)
+#define INSTR_PROF_COMMA
+#else
+#define INSTR_PROF_DATA_DEFINED
+#define INSTR_PROF_COMMA ,
+#endif
+VALUE_PROF_FUNC_PARAM(uint64_t, TargetValue, Type::getInt64Ty(Ctx)) \
+ INSTR_PROF_COMMA
+VALUE_PROF_FUNC_PARAM(void *, Data, Type::getInt8PtrTy(Ctx)) INSTR_PROF_COMMA
+VALUE_PROF_FUNC_PARAM(uint32_t, CounterIndex, Type::getInt32Ty(Ctx))
+#undef VALUE_PROF_FUNC_PARAM
+#undef INSTR_PROF_COMMA
+/* VALUE_PROF_FUNC_PARAM end */
+/* COVMAP_FUNC_RECORD start */
+/* Definition of member fields of the function record structure in coverage
+ * map.
+ */
#ifndef COVMAP_FUNC_RECORD
-#define COVMAP_FUNC_RECORD(Type, LLVMTypeVar, LLVMType, Name, Initializer)
+#define COVMAP_FUNC_RECORD(Type, LLVMType, Name, Initializer)
+#else
+#define INSTR_PROF_DATA_DEFINED
#endif
-
-// COVMAP_FUNC_RECORD_START
-COVMAP_FUNC_RECORD(const IntPtrT, Int8PtrTy, llvm::Type::getInt8PtrTy(Ctx), \
- NamePtr, llvm::ConstantExpr::getBitCast(NamePtr, Int8PtrTy))
-COVMAP_FUNC_RECORD(const uint32_t, Int32Ty, llvm::Type::getInt32Ty(Ctx), \
- NameSize, llvm::ConstantInt::get(Int32Ty, NameSize))
-COVMAP_FUNC_RECORD(const uint32_t, Int32Ty, llvm::Type::getInt32Ty(Ctx), \
- DataSize, llvm::ConstantInt::get(Int32Ty, DataSize))
-COVMAP_FUNC_RECORD(const uint64_t, Int64Ty, llvm::Type::getInt64Ty(Ctx), \
- FuncHash, llvm::ConstantInt::get(Int64Ty, FuncSize))
-// COVMAP_FUNC_RECORD_END
-
-#ifdef COVMAP_FUNC_RECORD
+COVMAP_FUNC_RECORD(const IntPtrT, llvm::Type::getInt8PtrTy(Ctx), \
+ NamePtr, llvm::ConstantExpr::getBitCast(NamePtr, \
+ llvm::Type::getInt8PtrTy(Ctx)))
+COVMAP_FUNC_RECORD(const uint32_t, llvm::Type::getInt32Ty(Ctx), NameSize, \
+ llvm::ConstantInt::get(llvm::Type::getInt32Ty(Ctx),\
+ NameValue.size()))
+COVMAP_FUNC_RECORD(const uint32_t, llvm::Type::getInt32Ty(Ctx), DataSize, \
+ llvm::ConstantInt::get(llvm::Type::getInt32Ty(Ctx),\
+ CoverageMapping.size()))
+COVMAP_FUNC_RECORD(const uint64_t, llvm::Type::getInt64Ty(Ctx), FuncHash, \
+ llvm::ConstantInt::get(llvm::Type::getInt64Ty(Ctx), FuncHash))
#undef COVMAP_FUNC_RECORD
-#endif
+/* COVMAP_FUNC_RECORD end. */