| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| |
| |
| #ifndef INSTR_PROF_VISIBILITY |
| #define INSTR_PROF_VISIBILITY |
| #endif |
|
|
| |
| |
| |
| |
| #ifndef INSTR_PROF_DATA |
| #define INSTR_PROF_DATA(Type, LLVMType, Name, Initializer) |
| #else |
| #define INSTR_PROF_DATA_DEFINED |
| #endif |
| INSTR_PROF_DATA(const uint64_t, llvm::Type::getInt64Ty(Ctx), NameRef, \ |
| ConstantInt::get(llvm::Type::getInt64Ty(Ctx), \ |
| IndexedInstrProf::ComputeHash(getPGOFuncNameVarInitializer(Inc->getName())))) |
| 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, IntPtrTy, CounterPtr, RelativeCounterPtr) |
| INSTR_PROF_DATA(const IntPtrT, IntPtrTy, BitmapPtr, RelativeBitmapPtr) |
| |
| |
| |
| |
| INSTR_PROF_DATA(const IntPtrT, llvm::PointerType::getUnqual(Ctx), FunctionPointer, \ |
| FunctionAddr) |
| INSTR_PROF_DATA(IntPtrT, llvm::PointerType::getUnqual(Ctx), Values, \ |
| ValuesPtrExpr) |
| INSTR_PROF_DATA(const uint32_t, llvm::Type::getInt32Ty(Ctx), NumCounters, \ |
| ConstantInt::get(llvm::Type::getInt32Ty(Ctx), NumCounters)) |
| INSTR_PROF_DATA(const uint16_t, Int16ArrayTy, NumValueSites[IPVK_Last+1], \ |
| ConstantArray::get(Int16ArrayTy, Int16ArrayVals)) \ |
| INSTR_PROF_DATA(const uint32_t, llvm::Type::getInt32Ty(Ctx), NumBitmapBytes, \ |
| ConstantInt::get(llvm::Type::getInt32Ty(Ctx), NumBitmapBytes)) |
| #undef INSTR_PROF_DATA |
| |
|
|
| |
| |
| |
| |
| #ifndef INSTR_PROF_VTABLE_DATA |
| #define INSTR_PROF_VTABLE_DATA(Type, LLVMType, Name, Initializer) |
| #else |
| #define INSTR_PROF_VTABLE_DATA_DEFINED |
| #endif |
| INSTR_PROF_VTABLE_DATA(const uint64_t, llvm::Type::getInt64Ty(Ctx), \ |
| VTableNameHash, ConstantInt::get(llvm::Type::getInt64Ty(Ctx), \ |
| IndexedInstrProf::ComputeHash(PGOVTableName))) |
| INSTR_PROF_VTABLE_DATA(const IntPtrT, llvm::PointerType::getUnqual(Ctx), \ |
| VTablePointer, VTableAddr) |
| INSTR_PROF_VTABLE_DATA(const uint32_t, llvm::Type::getInt32Ty(Ctx), VTableSize, \ |
| ConstantInt::get(llvm::Type::getInt32Ty(Ctx), \ |
| VTableSizeVal)) |
| #undef INSTR_PROF_VTABLE_DATA |
| |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| #ifndef INSTR_PROF_VALUE_NODE |
| #define INSTR_PROF_VALUE_NODE(Type, LLVMType, Name, Initializer) |
| #else |
| #define INSTR_PROF_DATA_DEFINED |
| #endif |
| INSTR_PROF_VALUE_NODE(uint64_t, llvm::Type::getInt64Ty(Ctx), Value, \ |
| ConstantInt::get(llvm::Type::GetInt64Ty(Ctx), 0)) |
| INSTR_PROF_VALUE_NODE(uint64_t, llvm::Type::getInt64Ty(Ctx), Count, \ |
| ConstantInt::get(llvm::Type::GetInt64Ty(Ctx), 0)) |
| INSTR_PROF_VALUE_NODE(PtrToNodeT, llvm::PointerType::getUnqual(Ctx), Next, \ |
| ConstantInt::get(llvm::PointerType::getUnqual(Ctx), 0)) |
| #undef INSTR_PROF_VALUE_NODE |
| |
|
|
| |
| |
| |
| |
| #ifndef INSTR_PROF_RAW_HEADER |
| #define INSTR_PROF_RAW_HEADER(Type, Name, Initializer) |
| #else |
| #define INSTR_PROF_DATA_DEFINED |
| #endif |
| INSTR_PROF_RAW_HEADER(uint64_t, Magic, __llvm_profile_get_magic()) |
| INSTR_PROF_RAW_HEADER(uint64_t, Version, __llvm_profile_get_version()) |
| INSTR_PROF_RAW_HEADER(uint64_t, BinaryIdsSize, __llvm_write_binary_ids(NULL)) |
| INSTR_PROF_RAW_HEADER(uint64_t, NumData, NumData) |
| INSTR_PROF_RAW_HEADER(uint64_t, PaddingBytesBeforeCounters, PaddingBytesBeforeCounters) |
| INSTR_PROF_RAW_HEADER(uint64_t, NumCounters, NumCounters) |
| INSTR_PROF_RAW_HEADER(uint64_t, PaddingBytesAfterCounters, PaddingBytesAfterCounters) |
| INSTR_PROF_RAW_HEADER(uint64_t, NumBitmapBytes, NumBitmapBytes) |
| INSTR_PROF_RAW_HEADER(uint64_t, PaddingBytesAfterBitmapBytes, PaddingBytesAfterBitmapBytes) |
| INSTR_PROF_RAW_HEADER(uint64_t, NamesSize, NamesSize) |
| INSTR_PROF_RAW_HEADER(uint64_t, CountersDelta, |
| (uintptr_t)CountersBegin - (uintptr_t)DataBegin) |
| INSTR_PROF_RAW_HEADER(uint64_t, BitmapDelta, |
| (uintptr_t)BitmapBegin - (uintptr_t)DataBegin) |
| INSTR_PROF_RAW_HEADER(uint64_t, NamesDelta, (uintptr_t)NamesBegin) |
| INSTR_PROF_RAW_HEADER(uint64_t, NumVTables, NumVTables) |
| INSTR_PROF_RAW_HEADER(uint64_t, VNamesSize, VNamesSize) |
| INSTR_PROF_RAW_HEADER(uint64_t, ValueKindLast, IPVK_Last) |
| #undef INSTR_PROF_RAW_HEADER |
| |
|
|
| |
| |
| |
| |
| #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, PointerType::getUnqual(Ctx)) INSTR_PROF_COMMA |
| VALUE_PROF_FUNC_PARAM(uint32_t, CounterIndex, Type::getInt32Ty(Ctx)) |
| #undef VALUE_PROF_FUNC_PARAM |
| #undef INSTR_PROF_COMMA |
| |
|
|
| |
| #ifndef VALUE_PROF_KIND |
| #define VALUE_PROF_KIND(Enumerator, Value, Descr) |
| #else |
| #define INSTR_PROF_DATA_DEFINED |
| #endif |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| VALUE_PROF_KIND(IPVK_IndirectCallTarget, 0, "indirect call target") |
| |
| VALUE_PROF_KIND(IPVK_MemOPSize, 1, "memory intrinsic functions size") |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| VALUE_PROF_KIND(IPVK_VTableTarget, 2, "The profiled address point of the vtable") |
| |
| |
| |
| |
| |
| VALUE_PROF_KIND(IPVK_First, IPVK_IndirectCallTarget, "first") |
| VALUE_PROF_KIND(IPVK_Last, IPVK_VTableTarget, "last") |
|
|
| #undef VALUE_PROF_KIND |
| |
|
|
| #undef COVMAP_V2_OR_V3 |
| #ifdef COVMAP_V2 |
| #define COVMAP_V2_OR_V3 |
| #endif |
| #ifdef COVMAP_V3 |
| #define COVMAP_V2_OR_V3 |
| #endif |
|
|
| |
| |
| |
| |
| #ifndef COVMAP_FUNC_RECORD |
| #define COVMAP_FUNC_RECORD(Type, LLVMType, Name, Initializer) |
| #else |
| #define INSTR_PROF_DATA_DEFINED |
| #endif |
| #ifdef COVMAP_V1 |
| COVMAP_FUNC_RECORD(const IntPtrT, llvm::PointerType::getUnqual(Ctx), \ |
| NamePtr, llvm::ConstantExpr::getBitCast(NamePtr, \ |
| llvm::PointerType::getUnqual(Ctx))) |
| COVMAP_FUNC_RECORD(const uint32_t, llvm::Type::getInt32Ty(Ctx), NameSize, \ |
| llvm::ConstantInt::get(llvm::Type::getInt32Ty(Ctx), \ |
| NameValue.size())) |
| #endif |
| #ifdef COVMAP_V2_OR_V3 |
| COVMAP_FUNC_RECORD(const int64_t, llvm::Type::getInt64Ty(Ctx), NameRef, \ |
| llvm::ConstantInt::get( \ |
| llvm::Type::getInt64Ty(Ctx), NameHash)) |
| #endif |
| 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)) |
| #ifdef COVMAP_V3 |
| COVMAP_FUNC_RECORD(const uint64_t, llvm::Type::getInt64Ty(Ctx), FilenamesRef, \ |
| llvm::ConstantInt::get( \ |
| llvm::Type::getInt64Ty(Ctx), FilenamesRef)) |
| COVMAP_FUNC_RECORD(const char, \ |
| llvm::ArrayType::get(llvm::Type::getInt8Ty(Ctx), \ |
| CoverageMapping.size()), \ |
| CoverageMapping, |
| llvm::ConstantDataArray::getRaw( \ |
| CoverageMapping, CoverageMapping.size(), \ |
| llvm::Type::getInt8Ty(Ctx))) |
| #endif |
| #undef COVMAP_FUNC_RECORD |
| |
|
|
| |
| |
| |
| #ifndef COVMAP_HEADER |
| #define COVMAP_HEADER(Type, LLVMType, Name, Initializer) |
| #else |
| #define INSTR_PROF_DATA_DEFINED |
| #endif |
| COVMAP_HEADER(uint32_t, Int32Ty, NRecords, \ |
| llvm::ConstantInt::get(Int32Ty, NRecords)) |
| COVMAP_HEADER(uint32_t, Int32Ty, FilenamesSize, \ |
| llvm::ConstantInt::get(Int32Ty, FilenamesSize)) |
| COVMAP_HEADER(uint32_t, Int32Ty, CoverageSize, \ |
| llvm::ConstantInt::get(Int32Ty, CoverageMappingSize)) |
| COVMAP_HEADER(uint32_t, Int32Ty, Version, \ |
| llvm::ConstantInt::get(Int32Ty, CovMapVersion::CurrentVersion)) |
| #undef COVMAP_HEADER |
| |
|
|
|
|
| #ifdef INSTR_PROF_SECT_ENTRY |
| #define INSTR_PROF_DATA_DEFINED |
| INSTR_PROF_SECT_ENTRY(IPSK_data, \ |
| INSTR_PROF_QUOTE(INSTR_PROF_DATA_COMMON), \ |
| INSTR_PROF_DATA_COFF, "__DATA,") |
| INSTR_PROF_SECT_ENTRY(IPSK_cnts, \ |
| INSTR_PROF_QUOTE(INSTR_PROF_CNTS_COMMON), \ |
| INSTR_PROF_CNTS_COFF, "__DATA,") |
| INSTR_PROF_SECT_ENTRY(IPSK_bitmap, \ |
| INSTR_PROF_QUOTE(INSTR_PROF_BITS_COMMON), \ |
| INSTR_PROF_BITS_COFF, "__DATA,") |
| INSTR_PROF_SECT_ENTRY(IPSK_name, \ |
| INSTR_PROF_QUOTE(INSTR_PROF_NAME_COMMON), \ |
| INSTR_PROF_NAME_COFF, "__DATA,") |
| INSTR_PROF_SECT_ENTRY(IPSK_vname, \ |
| INSTR_PROF_QUOTE(INSTR_PROF_VNAME_COMMON), \ |
| INSTR_PROF_VNAME_COFF, "__DATA,") |
| INSTR_PROF_SECT_ENTRY(IPSK_vals, \ |
| INSTR_PROF_QUOTE(INSTR_PROF_VALS_COMMON), \ |
| INSTR_PROF_VALS_COFF, "__DATA,") |
| INSTR_PROF_SECT_ENTRY(IPSK_vnodes, \ |
| INSTR_PROF_QUOTE(INSTR_PROF_VNODES_COMMON), \ |
| INSTR_PROF_VNODES_COFF, "__DATA,") |
| INSTR_PROF_SECT_ENTRY(IPSK_vtab, \ |
| INSTR_PROF_QUOTE(INSTR_PROF_VTAB_COMMON), \ |
| INSTR_PROF_VTAB_COFF, "__DATA,") |
| INSTR_PROF_SECT_ENTRY(IPSK_covmap, \ |
| INSTR_PROF_QUOTE(INSTR_PROF_COVMAP_COMMON), \ |
| INSTR_PROF_COVMAP_COFF, "__LLVM_COV,") |
| INSTR_PROF_SECT_ENTRY(IPSK_covfun, \ |
| INSTR_PROF_QUOTE(INSTR_PROF_COVFUN_COMMON), \ |
| INSTR_PROF_COVFUN_COFF, "__LLVM_COV,") |
| INSTR_PROF_SECT_ENTRY(IPSK_orderfile, \ |
| INSTR_PROF_QUOTE(INSTR_PROF_ORDERFILE_COMMON), \ |
| INSTR_PROF_QUOTE(INSTR_PROF_ORDERFILE_COFF), "__DATA,") |
| INSTR_PROF_SECT_ENTRY(IPSK_covdata, \ |
| INSTR_PROF_QUOTE(INSTR_PROF_COVDATA_COMMON), \ |
| INSTR_PROF_COVDATA_COFF, "__LLVM_COV,") |
| INSTR_PROF_SECT_ENTRY(IPSK_covname, \ |
| INSTR_PROF_QUOTE(INSTR_PROF_COVNAME_COMMON), \ |
| INSTR_PROF_COVNAME_COFF, "__LLVM_COV,") |
|
|
| #undef INSTR_PROF_SECT_ENTRY |
| #endif |
|
|
|
|
| #ifdef INSTR_PROF_VALUE_PROF_DATA |
| #define INSTR_PROF_DATA_DEFINED |
|
|
| #define INSTR_PROF_MAX_NUM_VAL_PER_SITE 255 |
| |
| |
| |
| |
| typedef struct ValueProfRecord { |
| |
| uint32_t Kind; |
| |
| |
| |
| |
| uint32_t NumValueSites; |
| |
| |
| |
| |
| |
| |
| uint8_t SiteCountArray[1]; |
|
|
| |
| |
| |
| |
| |
|
|
| |
| |
| |
| |
|
|
| #ifdef __cplusplus |
| |
| |
| |
| uint32_t getNumValueSites() const { return NumValueSites; } |
| |
| |
| |
| void deserializeTo(InstrProfRecord &Record, |
| InstrProfSymtab *SymTab); |
| |
| |
| |
| |
| |
| void swapBytes(llvm::endianness Old, llvm::endianness New); |
| #endif |
| } ValueProfRecord; |
|
|
| |
| |
| |
| |
| typedef struct ValueProfData { |
| |
| |
| |
| |
| uint32_t TotalSize; |
| |
| |
| |
| |
| |
| |
| |
| |
| uint32_t NumValueKinds; |
|
|
| |
| |
| |
| |
| |
| |
| |
|
|
| #if __cplusplus |
| |
| |
| |
| |
| static uint32_t getSize(const InstrProfRecord &Record); |
| |
| |
| |
| static std::unique_ptr<ValueProfData> |
| serializeFrom(const InstrProfRecord &Record); |
| |
| |
| |
| Error checkIntegrity(); |
| |
| |
| |
| |
| |
| static Expected<std::unique_ptr<ValueProfData>> |
| getValueProfData(const unsigned char *SrcBuffer, |
| const unsigned char *const SrcBufferEnd, |
| llvm::endianness SrcDataEndianness); |
| |
| |
| |
| void swapBytesToHost(llvm::endianness Endianness); |
| |
| |
| |
| void swapBytesFromHost(llvm::endianness Endianness); |
| |
| |
| |
| uint32_t getSize() const { return TotalSize; } |
| |
| |
| |
| void deserializeTo(InstrProfRecord &Record, |
| InstrProfSymtab *SymTab); |
| void operator delete(void *ptr) { ::operator delete(ptr); } |
| #endif |
| } ValueProfData; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| typedef struct ValueProfRecordClosure { |
| const void *Record; |
| uint32_t (*GetNumValueKinds)(const void *Record); |
| uint32_t (*GetNumValueSites)(const void *Record, uint32_t VKind); |
| uint32_t (*GetNumValueData)(const void *Record, uint32_t VKind); |
| uint32_t (*GetNumValueDataForSite)(const void *R, uint32_t VK, uint32_t S); |
|
|
| |
| |
| |
| |
| |
| uint64_t (*RemapValueData)(uint32_t, uint64_t Value); |
| void (*GetValueForSite)(const void *R, InstrProfValueData *Dst, uint32_t K, |
| uint32_t S); |
| ValueProfData *(*AllocValueProfData)(size_t TotalSizeInBytes); |
| } ValueProfRecordClosure; |
|
|
| INSTR_PROF_VISIBILITY ValueProfRecord * |
| getFirstValueProfRecord(ValueProfData *VPD); |
| INSTR_PROF_VISIBILITY ValueProfRecord * |
| getValueProfRecordNext(ValueProfRecord *VPR); |
| INSTR_PROF_VISIBILITY InstrProfValueData * |
| getValueProfRecordValueData(ValueProfRecord *VPR); |
| INSTR_PROF_VISIBILITY uint32_t |
| getValueProfRecordHeaderSize(uint32_t NumValueSites); |
|
|
| #undef INSTR_PROF_VALUE_PROF_DATA |
| #endif |
|
|
|
|
| #ifdef INSTR_PROF_COMMON_API_IMPL |
| #define INSTR_PROF_DATA_DEFINED |
| #ifdef __cplusplus |
| #define INSTR_PROF_INLINE inline |
| #define INSTR_PROF_NULLPTR nullptr |
| #else |
| #define INSTR_PROF_INLINE |
| #define INSTR_PROF_NULLPTR NULL |
| #endif |
|
|
| #ifndef offsetof |
| #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) |
| #endif |
|
|
| |
|
|
| |
| |
| |
| |
| INSTR_PROF_VISIBILITY INSTR_PROF_INLINE uint32_t |
| getValueProfRecordHeaderSize(uint32_t NumValueSites) { |
| uint32_t Size = offsetof(ValueProfRecord, SiteCountArray) + |
| sizeof(uint8_t) * NumValueSites; |
| |
| Size = (Size + 7) & ~7; |
| return Size; |
| } |
|
|
| |
| |
| |
| |
| INSTR_PROF_VISIBILITY INSTR_PROF_INLINE uint32_t |
| getValueProfRecordSize(uint32_t NumValueSites, uint32_t NumValueData) { |
| return getValueProfRecordHeaderSize(NumValueSites) + |
| sizeof(InstrProfValueData) * NumValueData; |
| } |
|
|
| |
| |
| |
| INSTR_PROF_VISIBILITY INSTR_PROF_INLINE InstrProfValueData * |
| getValueProfRecordValueData(ValueProfRecord *This) { |
| return (InstrProfValueData *)((char *)This + getValueProfRecordHeaderSize( |
| This->NumValueSites)); |
| } |
|
|
| |
| |
| |
| INSTR_PROF_VISIBILITY INSTR_PROF_INLINE uint32_t |
| getValueProfRecordNumValueData(ValueProfRecord *This) { |
| uint32_t NumValueData = 0; |
| uint32_t I; |
| for (I = 0; I < This->NumValueSites; I++) |
| NumValueData += This->SiteCountArray[I]; |
| return NumValueData; |
| } |
|
|
| |
| |
| |
| INSTR_PROF_VISIBILITY INSTR_PROF_INLINE ValueProfRecord * |
| getValueProfRecordNext(ValueProfRecord *This) { |
| uint32_t NumValueData = getValueProfRecordNumValueData(This); |
| return (ValueProfRecord *)((char *)This + |
| getValueProfRecordSize(This->NumValueSites, |
| NumValueData)); |
| } |
|
|
| |
| |
| |
| INSTR_PROF_VISIBILITY INSTR_PROF_INLINE ValueProfRecord * |
| getFirstValueProfRecord(ValueProfData *This) { |
| return (ValueProfRecord *)((char *)This + sizeof(ValueProfData)); |
| } |
|
|
| |
|
|
| |
| |
| |
| |
| INSTR_PROF_VISIBILITY uint32_t |
| getValueProfDataSize(ValueProfRecordClosure *Closure) { |
| uint32_t Kind; |
| uint32_t TotalSize = sizeof(ValueProfData); |
| const void *Record = Closure->Record; |
|
|
| for (Kind = IPVK_First; Kind <= IPVK_Last; Kind++) { |
| uint32_t NumValueSites = Closure->GetNumValueSites(Record, Kind); |
| if (!NumValueSites) |
| continue; |
| TotalSize += getValueProfRecordSize(NumValueSites, |
| Closure->GetNumValueData(Record, Kind)); |
| } |
| return TotalSize; |
| } |
|
|
| |
| |
| |
| |
| INSTR_PROF_VISIBILITY void |
| serializeValueProfRecordFrom(ValueProfRecord *This, |
| ValueProfRecordClosure *Closure, |
| uint32_t ValueKind, uint32_t NumValueSites) { |
| uint32_t S; |
| const void *Record = Closure->Record; |
| This->Kind = ValueKind; |
| This->NumValueSites = NumValueSites; |
| InstrProfValueData *DstVD = getValueProfRecordValueData(This); |
|
|
| for (S = 0; S < NumValueSites; S++) { |
| uint32_t ND = Closure->GetNumValueDataForSite(Record, ValueKind, S); |
| This->SiteCountArray[S] = ND; |
| Closure->GetValueForSite(Record, DstVD, ValueKind, S); |
| DstVD += ND; |
| } |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| INSTR_PROF_VISIBILITY ValueProfData * |
| serializeValueProfDataFrom(ValueProfRecordClosure *Closure, |
| ValueProfData *DstData) { |
| uint32_t Kind; |
| uint32_t TotalSize = |
| DstData ? DstData->TotalSize : getValueProfDataSize(Closure); |
|
|
| ValueProfData *VPD = |
| DstData ? DstData : Closure->AllocValueProfData(TotalSize); |
|
|
| VPD->TotalSize = TotalSize; |
| VPD->NumValueKinds = Closure->GetNumValueKinds(Closure->Record); |
| ValueProfRecord *VR = getFirstValueProfRecord(VPD); |
| for (Kind = IPVK_First; Kind <= IPVK_Last; Kind++) { |
| uint32_t NumValueSites = Closure->GetNumValueSites(Closure->Record, Kind); |
| if (!NumValueSites) |
| continue; |
| serializeValueProfRecordFrom(VR, Closure, Kind, NumValueSites); |
| VR = getValueProfRecordNext(VR); |
| } |
| return VPD; |
| } |
|
|
| #undef INSTR_PROF_COMMON_API_IMPL |
| #endif |
|
|
| |
|
|
| |
| |
| #ifndef INSTR_PROF_DATA_DEFINED |
|
|
| #ifndef INSTR_PROF_DATA_INC |
| #define INSTR_PROF_DATA_INC |
|
|
| |
| #define INSTR_PROF_SIMPLE_QUOTE(x) #x |
| #define INSTR_PROF_QUOTE(x) INSTR_PROF_SIMPLE_QUOTE(x) |
| #define INSTR_PROF_SIMPLE_CONCAT(x,y) x ## y |
| #define INSTR_PROF_CONCAT(x,y) INSTR_PROF_SIMPLE_CONCAT(x,y) |
|
|
| |
| |
| |
| |
| |
| |
| |
| #define INSTR_PROF_RAW_MAGIC_64 (uint64_t)255 << 56 | (uint64_t)'l' << 48 | \ |
| (uint64_t)'p' << 40 | (uint64_t)'r' << 32 | (uint64_t)'o' << 24 | \ |
| (uint64_t)'f' << 16 | (uint64_t)'r' << 8 | (uint64_t)129 |
| #define INSTR_PROF_RAW_MAGIC_32 (uint64_t)255 << 56 | (uint64_t)'l' << 48 | \ |
| (uint64_t)'p' << 40 | (uint64_t)'r' << 32 | (uint64_t)'o' << 24 | \ |
| (uint64_t)'f' << 16 | (uint64_t)'R' << 8 | (uint64_t)129 |
|
|
| |
| #define INSTR_PROF_RAW_VERSION 10 |
| |
| #define INSTR_PROF_INDEX_VERSION 12 |
| |
| #define INSTR_PROF_COVMAP_VERSION 6 |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| #define VARIANT_MASKS_ALL 0xffffffff00000000ULL |
| #define GET_VERSION(V) ((V) & ~VARIANT_MASKS_ALL) |
| #define VARIANT_MASK_IR_PROF (0x1ULL << 56) |
| #define VARIANT_MASK_CSIR_PROF (0x1ULL << 57) |
| #define VARIANT_MASK_INSTR_ENTRY (0x1ULL << 58) |
| #define VARIANT_MASK_DBG_CORRELATE (0x1ULL << 59) |
| #define VARIANT_MASK_BYTE_COVERAGE (0x1ULL << 60) |
| #define VARIANT_MASK_FUNCTION_ENTRY_ONLY (0x1ULL << 61) |
| #define VARIANT_MASK_MEMPROF (0x1ULL << 62) |
| #define VARIANT_MASK_TEMPORAL_PROF (0x1ULL << 63) |
| #define INSTR_PROF_RAW_VERSION_VAR __llvm_profile_raw_version |
| #define INSTR_PROF_PROFILE_RUNTIME_VAR __llvm_profile_runtime |
| #define INSTR_PROF_PROFILE_COUNTER_BIAS_VAR __llvm_profile_counter_bias |
| #define INSTR_PROF_PROFILE_SET_TIMESTAMP __llvm_profile_set_timestamp |
| #define INSTR_PROF_PROFILE_SAMPLING_VAR __llvm_profile_sampling |
|
|
| |
| |
| #define INSTR_PROF_PROFILE_NAME_VAR __llvm_profile_filename |
|
|
| |
| |
| #define INSTR_PROF_DATA_COMMON __llvm_prf_data |
| #define INSTR_PROF_NAME_COMMON __llvm_prf_names |
| #define INSTR_PROF_VNAME_COMMON __llvm_prf_vns |
| #define INSTR_PROF_CNTS_COMMON __llvm_prf_cnts |
| #define INSTR_PROF_BITS_COMMON __llvm_prf_bits |
| #define INSTR_PROF_VALS_COMMON __llvm_prf_vals |
| #define INSTR_PROF_VNODES_COMMON __llvm_prf_vnds |
| #define INSTR_PROF_VTAB_COMMON __llvm_prf_vtab |
| #define INSTR_PROF_COVMAP_COMMON __llvm_covmap |
| #define INSTR_PROF_COVFUN_COMMON __llvm_covfun |
| #define INSTR_PROF_COVDATA_COMMON __llvm_covdata |
| #define INSTR_PROF_COVNAME_COMMON __llvm_covnames |
| #define INSTR_PROF_ORDERFILE_COMMON __llvm_orderfile |
| |
| |
| |
| #define INSTR_PROF_DATA_COFF ".lprfd$M" |
| #define INSTR_PROF_NAME_COFF ".lprfn$M" |
| #define INSTR_PROF_VNAME_COFF ".lprfvn$M" |
| #define INSTR_PROF_CNTS_COFF ".lprfc$M" |
| #define INSTR_PROF_BITS_COFF ".lprfb$M" |
| #define INSTR_PROF_VALS_COFF ".lprfv$M" |
| #define INSTR_PROF_VNODES_COFF ".lprfnd$M" |
| #define INSTR_PROF_VTAB_COFF ".lprfvt$M" |
| #define INSTR_PROF_COVMAP_COFF ".lcovmap$M" |
| #define INSTR_PROF_COVFUN_COFF ".lcovfun$M" |
| |
| |
| |
| #define INSTR_PROF_COVDATA_COFF ".lcovd" |
| #define INSTR_PROF_COVNAME_COFF ".lcovn" |
| #define INSTR_PROF_ORDERFILE_COFF ".lorderfile$M" |
|
|
| #ifdef _WIN32 |
| |
| #define INSTR_PROF_DATA_SECT_NAME INSTR_PROF_DATA_COFF |
| #define INSTR_PROF_NAME_SECT_NAME INSTR_PROF_NAME_COFF |
| #define INSTR_PROF_CNTS_SECT_NAME INSTR_PROF_CNTS_COFF |
| #define INSTR_PROF_BITS_SECT_NAME INSTR_PROF_BITS_COFF |
| #define INSTR_PROF_VTAB_SECT_NAME INSTR_PROF_VTAB_COFF |
| #define INSTR_PROF_VNAME_SECT_NAME INSTR_PROF_VNAME_COFF |
| |
| |
| |
| #define INSTR_PROF_VALS_SECT_NAME INSTR_PROF_VALS_COFF |
| |
| #define INSTR_PROF_VNODES_SECT_NAME INSTR_PROF_VNODES_COFF |
| #define INSTR_PROF_COVMAP_SECT_NAME INSTR_PROF_COVMAP_COFF |
| #define INSTR_PROF_COVFUN_SECT_NAME INSTR_PROF_COVFUN_COFF |
| #define INSTR_PROF_COVDATA_SECT_NAME INSTR_PROF_COVDATA_COFF |
| #define INSTR_PROF_COVNAME_SECT_NAME INSTR_PROF_COVNAME_COFF |
| #define INSTR_PROF_ORDERFILE_SECT_NAME INSTR_PROF_ORDERFILE_COFF |
| #else |
| |
| #define INSTR_PROF_DATA_SECT_NAME INSTR_PROF_QUOTE(INSTR_PROF_DATA_COMMON) |
| #define INSTR_PROF_NAME_SECT_NAME INSTR_PROF_QUOTE(INSTR_PROF_NAME_COMMON) |
| #define INSTR_PROF_CNTS_SECT_NAME INSTR_PROF_QUOTE(INSTR_PROF_CNTS_COMMON) |
| #define INSTR_PROF_BITS_SECT_NAME INSTR_PROF_QUOTE(INSTR_PROF_BITS_COMMON) |
| #define INSTR_PROF_VTAB_SECT_NAME INSTR_PROF_QUOTE(INSTR_PROF_VTAB_COMMON) |
| #define INSTR_PROF_VNAME_SECT_NAME INSTR_PROF_QUOTE(INSTR_PROF_VNAME_COMMON) |
| |
| |
| |
| #define INSTR_PROF_VALS_SECT_NAME INSTR_PROF_QUOTE(INSTR_PROF_VALS_COMMON) |
| |
| #define INSTR_PROF_VNODES_SECT_NAME INSTR_PROF_QUOTE(INSTR_PROF_VNODES_COMMON) |
| #define INSTR_PROF_COVMAP_SECT_NAME INSTR_PROF_QUOTE(INSTR_PROF_COVMAP_COMMON) |
| #define INSTR_PROF_COVFUN_SECT_NAME INSTR_PROF_QUOTE(INSTR_PROF_COVFUN_COMMON) |
| #define INSTR_PROF_COVDATA_SECT_NAME INSTR_PROF_QUOTE(INSTR_PROF_COVDATA_COMMON) |
| #define INSTR_PROF_COVNAME_SECT_NAME INSTR_PROF_QUOTE(INSTR_PROF_COVNAME_COMMON) |
| |
| #define INSTR_PROF_ORDERFILE_SECT_NAME \ |
| INSTR_PROF_QUOTE(INSTR_PROF_ORDERFILE_COMMON) |
| #endif |
|
|
| #define INSTR_PROF_ORDERFILE_BUFFER_NAME _llvm_order_file_buffer |
| #define INSTR_PROF_ORDERFILE_BUFFER_NAME_STR \ |
| INSTR_PROF_QUOTE(INSTR_PROF_ORDERFILE_BUFFER_NAME) |
| #define INSTR_PROF_ORDERFILE_BUFFER_IDX_NAME _llvm_order_file_buffer_idx |
| #define INSTR_PROF_ORDERFILE_BUFFER_IDX_NAME_STR \ |
| INSTR_PROF_QUOTE(INSTR_PROF_ORDERFILE_BUFFER_IDX_NAME) |
|
|
| |
| |
| |
| |
| |
| #define INSTR_PROF_SECT_START(Sect) \ |
| INSTR_PROF_CONCAT(__start_,Sect) |
| #define INSTR_PROF_SECT_STOP(Sect) \ |
| INSTR_PROF_CONCAT(__stop_,Sect) |
|
|
| |
| #define INSTR_PROF_VALUE_PROF_FUNC __llvm_profile_instrument_target |
| #define INSTR_PROF_VALUE_PROF_FUNC_STR \ |
| INSTR_PROF_QUOTE(INSTR_PROF_VALUE_PROF_FUNC) |
| #define INSTR_PROF_VALUE_PROF_MEMOP_FUNC __llvm_profile_instrument_memop |
| #define INSTR_PROF_VALUE_PROF_MEMOP_FUNC_STR \ |
| INSTR_PROF_QUOTE(INSTR_PROF_VALUE_PROF_MEMOP_FUNC) |
|
|
| |
| #define INSTR_PROF_DATA_ALIGNMENT 8 |
|
|
| |
| |
| |
| typedef struct InstrProfValueData { |
| |
| uint64_t Value; |
| |
| uint64_t Count; |
| } InstrProfValueData; |
|
|
| #endif |
|
|
| #ifndef INSTR_ORDER_FILE_INC |
| |
| #define INSTR_ORDER_FILE_BUFFER_SIZE 131072 |
| #define INSTR_ORDER_FILE_BUFFER_BITS 17 |
| #define INSTR_ORDER_FILE_BUFFER_MASK 0x1ffff |
| #endif |
| #else |
| #undef INSTR_PROF_DATA_DEFINED |
| #endif |
|
|
| #undef COVMAP_V2_OR_V3 |
|
|
| #ifdef INSTR_PROF_VALUE_PROF_MEMOP_API |
|
|
| #ifdef __cplusplus |
| #define INSTR_PROF_INLINE inline |
| #else |
| #define INSTR_PROF_INLINE |
| #endif |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| #define INSTR_PROF_NUM_BUCKETS 22 |
|
|
| |
| |
| |
| |
| |
| #if defined(_MSC_VER) && !defined(__clang__) |
|
|
| #include <intrin.h> |
| INSTR_PROF_VISIBILITY INSTR_PROF_INLINE |
| int InstProfClzll(unsigned long long X) { |
| unsigned long LeadZeroIdx = 0; |
| #if !defined(_M_ARM64) && !defined(_M_X64) |
| |
| if (_BitScanReverse(&LeadZeroIdx, (unsigned long)(X >> 32))) |
| return (int)(63 - (LeadZeroIdx + 32)); |
| |
| |
| if (_BitScanReverse(&LeadZeroIdx, (unsigned long)(X))) |
| return (int)(63 - LeadZeroIdx); |
| #else |
| if (_BitScanReverse64(&LeadZeroIdx, X)) return 63 - LeadZeroIdx; |
| #endif |
| return 64; |
| } |
| INSTR_PROF_VISIBILITY INSTR_PROF_INLINE |
| int InstProfPopcountll(unsigned long long X) { |
| |
| unsigned long long v = X; |
| v = v - ((v >> 1) & 0x5555555555555555ULL); |
| v = (v & 0x3333333333333333ULL) + ((v >> 2) & 0x3333333333333333ULL); |
| v = (v + (v >> 4)) & 0x0F0F0F0F0F0F0F0FULL; |
| return (int)((unsigned long long)(v * 0x0101010101010101ULL) >> 56); |
| } |
|
|
| #else |
|
|
| INSTR_PROF_VISIBILITY INSTR_PROF_INLINE |
| int InstProfClzll(unsigned long long X) { return __builtin_clzll(X); } |
| INSTR_PROF_VISIBILITY INSTR_PROF_INLINE |
| int InstProfPopcountll(unsigned long long X) { return __builtin_popcountll(X); } |
|
|
| #endif |
|
|
| |
|
|
| |
| |
| INSTR_PROF_VISIBILITY INSTR_PROF_INLINE uint64_t |
| InstrProfGetRangeRepValue(uint64_t Value) { |
| if (Value <= 8) |
| |
| return Value; |
| else if (Value >= 513) |
| |
| return 513; |
| else if (InstProfPopcountll(Value) == 1) |
| |
| return Value; |
| else |
| |
| return (UINT64_C(1) << (64 - InstProfClzll(Value) - 1)) + 1; |
| } |
|
|
| |
| |
| |
| INSTR_PROF_VISIBILITY INSTR_PROF_INLINE unsigned |
| InstrProfIsSingleValRange(uint64_t Value) { |
| if (Value <= 8) |
| |
| return 1; |
| else if (InstProfPopcountll(Value) == 1) |
| |
| return 1; |
| else |
| |
| return 0; |
| } |
|
|
| #endif |
|
|