================
@@ -821,15 +822,23 @@ void InstrProfRecord::merge(InstrProfRecord &Other, 
uint64_t Weight,
 
   for (size_t I = 0, E = Other.Counts.size(); I < E; ++I) {
     bool Overflowed;
-    uint64_t Value =
-        SaturatingMultiplyAdd(Other.Counts[I], Weight, Counts[I], &Overflowed);
-    if (Value > getInstrMaxCountValue()) {
-      Value = getInstrMaxCountValue();
-      Overflowed = true;
+    uint64_t Value;
+    // When a profile has single byte coverage, use || to merge counters.
+    if (HasSingleByteCoverage)
+      Value = Other.Counts[I] || Counts[I];
----------------
ellishg wrote:

As I understand, this is needed so that when we merge multiple raw coverage 
profiles we get an indexed profile with counters that are either 0 or 1.
If we instead merge by adding counters, we would get technically inaccurate 
counts. However, they would be accurate if interpreted for coverage, i.e., 0 is 
not covered and >0 is covered. In addition, indexed profiles would have more 
information because if a counter is large, we know it is commonly executed 
because it was covered in many raw profiles.
Do you think it makes sense to merge these as counters for the indexed profile 
and simply interpret them as coverage?

https://github.com/llvm/llvm-project/pull/75425
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to