Index: include/llvm/ProfileData/InstrProf.h =================================================================== --- include/llvm/ProfileData/InstrProf.h +++ include/llvm/ProfileData/InstrProf.h @@ -214,9 +214,11 @@ /// Get the value profile data for value site \p SiteIdx from \p InstrProfR /// and annotate the instruction \p Inst with the value profile meta data. +/// Annotate up to \p MaxMDCount (default 3) number of records per value site. void annotateValueSite(Module &M, Instruction &Inst, const InstrProfRecord &InstrProfR, - InstrProfValueKind ValueKind, uint32_t SiteIndx); + InstrProfValueKind ValueKind, uint32_t SiteIndx, + uint32_t MaxMDCount = 3); /// Extract the value profile data from \p Inst which is annotated with /// value profile meta data. Return false if there is no value data annotated, /// otherwise return true. Index: lib/ProfileData/InstrProf.cpp =================================================================== --- lib/ProfileData/InstrProf.cpp +++ lib/ProfileData/InstrProf.cpp @@ -591,7 +591,8 @@ void annotateValueSite(Module &M, Instruction &Inst, const InstrProfRecord &InstrProfR, - InstrProfValueKind ValueKind, uint32_t SiteIdx) { + InstrProfValueKind ValueKind, uint32_t SiteIdx, + uint32_t MaxMDCount) { uint32_t NV = InstrProfR.getNumValueDataForSite(ValueKind, SiteIdx); uint64_t Sum = 0; @@ -611,7 +612,7 @@ MDHelper.createConstant(ConstantInt::get(Type::getInt64Ty(Ctx), Sum))); // Value Profile Data - uint32_t MDCount = 3; + uint32_t MDCount = MaxMDCount; for (uint32_t I = 0; I < NV; ++I) { Vals.push_back(MDHelper.createConstant( ConstantInt::get(Type::getInt64Ty(Ctx), VD[I].Value)));