@@ -788,25 +788,23 @@ SampleProfileLoader::findFunctionSamples(const Instruction &Inst) const {
788
788
// / NOMORE_ICP_MAGICNUM count values in the value profile of \p Inst, we
789
789
// / cannot promote for \p Inst anymore.
790
790
static bool doesHistoryAllowICP (const Instruction &Inst, StringRef Candidate) {
791
- uint32_t NumVals = 0 ;
792
791
uint64_t TotalCount = 0 ;
793
- auto ValueData =
794
- getValueProfDataFromInst (Inst, IPVK_IndirectCallTarget, MaxNumPromotions,
795
- NumVals, TotalCount, true );
792
+ auto ValueData = getValueProfDataFromInst (Inst, IPVK_IndirectCallTarget,
793
+ MaxNumPromotions, TotalCount, true );
796
794
// No valid value profile so no promoted targets have been recorded
797
795
// before. Ok to do ICP.
798
- if (! ValueData)
796
+ if (ValueData. empty () )
799
797
return true ;
800
798
801
799
unsigned NumPromoted = 0 ;
802
- for (uint32_t I = 0 ; I < NumVals; I++ ) {
803
- if (ValueData[I] .Count != NOMORE_ICP_MAGICNUM)
800
+ for (const auto &V : ValueData ) {
801
+ if (V .Count != NOMORE_ICP_MAGICNUM)
804
802
continue ;
805
803
806
804
// If the promotion candidate has NOMORE_ICP_MAGICNUM count in the
807
805
// metadata, it means the candidate has been promoted for this
808
806
// indirect call.
809
- if (ValueData[I] .Value == Function::getGUID (Candidate))
807
+ if (V .Value == Function::getGUID (Candidate))
810
808
return false ;
811
809
NumPromoted++;
812
810
// If already have MaxNumPromotions promotion, don't do it anymore.
@@ -832,11 +830,10 @@ updateIDTMetaData(Instruction &Inst,
832
830
// `MaxNumPromotions` inside it.
833
831
if (MaxNumPromotions == 0 )
834
832
return ;
835
- uint32_t NumVals = 0 ;
836
833
// OldSum is the existing total count in the value profile data.
837
834
uint64_t OldSum = 0 ;
838
- auto ValueData = getValueProfDataFromInst (
839
- Inst, IPVK_IndirectCallTarget, MaxNumPromotions, NumVals , OldSum, true );
835
+ auto ValueData = getValueProfDataFromInst (Inst, IPVK_IndirectCallTarget,
836
+ MaxNumPromotions , OldSum, true );
840
837
841
838
DenseMap<uint64_t , uint64_t > ValueCountMap;
842
839
if (Sum == 0 ) {
@@ -845,10 +842,8 @@ updateIDTMetaData(Instruction &Inst,
845
842
" If sum is 0, assume only one element in CallTargets "
846
843
" with count being NOMORE_ICP_MAGICNUM" );
847
844
// Initialize ValueCountMap with existing value profile data.
848
- if (ValueData) {
849
- for (uint32_t I = 0 ; I < NumVals; I++)
850
- ValueCountMap[ValueData[I].Value ] = ValueData[I].Count ;
851
- }
845
+ for (const auto &V : ValueData)
846
+ ValueCountMap[V.Value ] = V.Count ;
852
847
auto Pair =
853
848
ValueCountMap.try_emplace (CallTargets[0 ].Value , CallTargets[0 ].Count );
854
849
// If the target already exists in value profile, decrease the total
@@ -861,11 +856,9 @@ updateIDTMetaData(Instruction &Inst,
861
856
} else {
862
857
// Initialize ValueCountMap with existing NOMORE_ICP_MAGICNUM
863
858
// counts in the value profile.
864
- if (ValueData) {
865
- for (uint32_t I = 0 ; I < NumVals; I++) {
866
- if (ValueData[I].Count == NOMORE_ICP_MAGICNUM)
867
- ValueCountMap[ValueData[I].Value ] = ValueData[I].Count ;
868
- }
859
+ for (const auto &V : ValueData) {
860
+ if (V.Count == NOMORE_ICP_MAGICNUM)
861
+ ValueCountMap[V.Value ] = V.Count ;
869
862
}
870
863
871
864
for (const auto &Data : CallTargets) {
0 commit comments