[llvm] [llvm-cov] Option to ignore hash mismatches for non-emitted symbols (PR #97574)
Aleksa Marković via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 9 02:40:07 PDT 2024
================
@@ -1501,6 +1506,11 @@ Expected<InstrProfRecord> IndexedInstrProfReader::getInstrProfRecord(
}
// Found it. Look for counters with the right hash.
+ // Ignore possible hash mismatch if hash is 0.
+ if (IgnoreEmptyHashMismatches && FuncHash == 0x0 && Data.size() == 1) {
----------------
ntnx-aleksa wrote:
Thank you for noticing this shortcoming of the solution.
The FuncName and FuncHash arguments originate from the object file, and the reader is used to look up through the indexed profile file. The problem we have is that hashes are required to match a function, yet we don't have a correct hash for non-emitted functions. For non emitted hashes, we have a hash of 0. We could also have functions with a true zero hash value - these would be certain to have a FuncHash = 0x0 and an equivalent hash of 0 in the profile file, and should naturally match.
At this point, the Data array contains records for the same FuncName, but with different hashes.
If we have FuncHash = 0 because the function is not emitted, the profile could contain symbols with different hashes. My idea was if there's only one of these symbols, match them. If there's more, maybe there is one which will match, or maybe not, so we should continue with the regular check below.
If we have a true FuncHash = 0 and we provide an unrelated profile data file with a non-zero hash for a function of the same name, this would falsely match it.
I suppose I could extend the condition to check if `Data[0].Hash != 0`. Then we would be sure not to catch these.
```suggestion
if (IgnoreEmptyHashMismatches && FuncHash == 0x0 && Data.size() == 1 && Data.front().Hash != 0x0) {
```
https://github.com/llvm/llvm-project/pull/97574
More information about the llvm-commits
mailing list