}
/// 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();
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;
}
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.
}
// 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)
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;
}
};
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())
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;
}