@@ -790,14 +790,12 @@ SampleProfileLoader::findFunctionSamples(const Instruction &Inst) const {
790
790
static bool doesHistoryAllowICP (const Instruction &Inst, StringRef Candidate) {
791
791
uint32_t NumVals = 0 ;
792
792
uint64_t TotalCount = 0 ;
793
- std::unique_ptr<InstrProfValueData[]> ValueData =
794
- std::make_unique<InstrProfValueData[]>(MaxNumPromotions);
795
- bool Valid =
793
+ auto ValueData =
796
794
getValueProfDataFromInst (Inst, IPVK_IndirectCallTarget, MaxNumPromotions,
797
- ValueData. get (), NumVals, TotalCount, true );
795
+ NumVals, TotalCount, true );
798
796
// No valid value profile so no promoted targets have been recorded
799
797
// before. Ok to do ICP.
800
- if (!Valid )
798
+ if (!ValueData )
801
799
return true ;
802
800
803
801
unsigned NumPromoted = 0 ;
@@ -837,11 +835,8 @@ updateIDTMetaData(Instruction &Inst,
837
835
uint32_t NumVals = 0 ;
838
836
// OldSum is the existing total count in the value profile data.
839
837
uint64_t OldSum = 0 ;
840
- std::unique_ptr<InstrProfValueData[]> ValueData =
841
- std::make_unique<InstrProfValueData[]>(MaxNumPromotions);
842
- bool Valid =
843
- getValueProfDataFromInst (Inst, IPVK_IndirectCallTarget, MaxNumPromotions,
844
- ValueData.get (), NumVals, OldSum, true );
838
+ auto ValueData = getValueProfDataFromInst (
839
+ Inst, IPVK_IndirectCallTarget, MaxNumPromotions, NumVals, OldSum, true );
845
840
846
841
DenseMap<uint64_t , uint64_t > ValueCountMap;
847
842
if (Sum == 0 ) {
@@ -850,7 +845,7 @@ updateIDTMetaData(Instruction &Inst,
850
845
" If sum is 0, assume only one element in CallTargets "
851
846
" with count being NOMORE_ICP_MAGICNUM" );
852
847
// Initialize ValueCountMap with existing value profile data.
853
- if (Valid ) {
848
+ if (ValueData ) {
854
849
for (uint32_t I = 0 ; I < NumVals; I++)
855
850
ValueCountMap[ValueData[I].Value ] = ValueData[I].Count ;
856
851
}
@@ -866,7 +861,7 @@ updateIDTMetaData(Instruction &Inst,
866
861
} else {
867
862
// Initialize ValueCountMap with existing NOMORE_ICP_MAGICNUM
868
863
// counts in the value profile.
869
- if (Valid ) {
864
+ if (ValueData ) {
870
865
for (uint32_t I = 0 ; I < NumVals; I++) {
871
866
if (ValueData[I].Count == NOMORE_ICP_MAGICNUM)
872
867
ValueCountMap[ValueData[I].Value ] = ValueData[I].Count ;
0 commit comments