Revert "[llvm-profdata] Add support for weighted merge of profile data"
[oota-llvm.git] / include / llvm / ProfileData / InstrProf.h
index e1ed2e9ce48c995b2cc562cc44931c45dbcfee80..95648511910298c5e73e27cc04d05f6babd6703c 100644 (file)
@@ -218,8 +218,7 @@ struct InstrProfValueSiteRecord {
   }
 
   /// Merge data from another InstrProfValueSiteRecord
-  /// Optionally scale merged counts by \p Weight.
-  void mergeValueData(InstrProfValueSiteRecord &Input, uint64_t Weight = 1) {
+  void mergeValueData(InstrProfValueSiteRecord &Input) {
     this->sortByTargetValues();
     Input.sortByTargetValues();
     auto I = ValueData.begin();
@@ -229,11 +228,7 @@ struct InstrProfValueSiteRecord {
       while (I != IE && I->Value < J->Value)
         ++I;
       if (I != IE && I->Value == J->Value) {
-        // TODO: Check for counter overflow and return error if it occurs.
-        uint64_t JCount = J->Count;
-        if (Weight > 1)
-          JCount = SaturatingMultiply(JCount, Weight);
-        I->Count = SaturatingAdd(I->Count, JCount);
+        I->Count = SaturatingAdd(I->Count, J->Count);
         ++I;
         continue;
       }
@@ -279,8 +274,7 @@ struct InstrProfRecord {
                            ValueMapType *HashKeys);
 
   /// Merge the counts in \p Other into this one.
-  /// Optionally scale merged counts by \p Weight.
-  inline instrprof_error merge(InstrProfRecord &Other, uint64_t Weight = 1);
+  inline instrprof_error merge(InstrProfRecord &Other);
 
   /// Used by InstrProfWriter: update the value strings to commoned strings in
   /// the writer instance.
@@ -332,9 +326,7 @@ private:
   }
 
   // Merge Value Profile data from Src record to this record for ValueKind.
-  // Scale merged value counts by \p Weight.
-  instrprof_error mergeValueProfData(uint32_t ValueKind, InstrProfRecord &Src,
-                                     uint64_t Weight) {
+  instrprof_error mergeValueProfData(uint32_t ValueKind, InstrProfRecord &Src) {
     uint32_t ThisNumValueSites = getNumValueSites(ValueKind);
     uint32_t OtherNumValueSites = Src.getNumValueSites(ValueKind);
     if (ThisNumValueSites != OtherNumValueSites)
@@ -344,7 +336,7 @@ private:
     std::vector<InstrProfValueSiteRecord> &OtherSiteRecords =
         Src.getValueSitesForKind(ValueKind);
     for (uint32_t I = 0; I < ThisNumValueSites; I++)
-      ThisSiteRecords[I].mergeValueData(OtherSiteRecords[I], Weight);
+      ThisSiteRecords[I].mergeValueData(OtherSiteRecords[I]);
     return instrprof_error::success;
   }
 };
@@ -430,8 +422,7 @@ void InstrProfRecord::updateStrings(InstrProfStringTable *StrTab) {
       VData.Value = (uint64_t)StrTab->insertString((const char *)VData.Value);
 }
 
-instrprof_error InstrProfRecord::merge(InstrProfRecord &Other,
-                                       uint64_t Weight) {
+instrprof_error InstrProfRecord::merge(InstrProfRecord &Other) {
   // If the number of counters doesn't match we either have bad data
   // or a hash collision.
   if (Counts.size() != Other.Counts.size())
@@ -441,19 +432,13 @@ instrprof_error InstrProfRecord::merge(InstrProfRecord &Other,
 
   for (size_t I = 0, E = Other.Counts.size(); I < E; ++I) {
     bool ResultOverflowed;
-    uint64_t OtherCount = Other.Counts[I];
-    if (Weight > 1) {
-      OtherCount = SaturatingMultiply(OtherCount, Weight, ResultOverflowed);
-      if (ResultOverflowed)
-        Result = instrprof_error::counter_overflow;
-    }
-    Counts[I] = SaturatingAdd(Counts[I], OtherCount, ResultOverflowed);
+    Counts[I] = SaturatingAdd(Counts[I], Other.Counts[I], ResultOverflowed);
     if (ResultOverflowed)
       Result = instrprof_error::counter_overflow;
   }
 
   for (uint32_t Kind = IPVK_First; Kind <= IPVK_Last; ++Kind) {
-    instrprof_error MergeValueResult = mergeValueProfData(Kind, Other, Weight);
+    instrprof_error MergeValueResult = mergeValueProfData(Kind, Other);
     if (MergeValueResult != instrprof_error::success)
       Result = MergeValueResult;
   }