[llvm] [llvm-profdata] Emit error when counter value is greater than 2^56. (PR #69513)
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 18 16:21:36 PDT 2023
================
@@ -676,8 +679,14 @@ Error RawInstrProfReader<IntPtrT>::readRawCounts(
// A value of zero signifies the block is covered.
Record.Counts.push_back(*Ptr == 0 ? 1 : 0);
} else {
- const auto *CounterValue = reinterpret_cast<const uint64_t *>(Ptr);
- Record.Counts.push_back(swap(*CounterValue));
+ uint64_t CounterValue = swap(*reinterpret_cast<const uint64_t *>(Ptr));
+ if (CounterValue > MaxCounterValue)
+ return error(instrprof_error::malformed,
+ ("counter value " + Twine(CounterValue) +
+ " is greater than " + Twine(MaxCounterValue))
+ .str());
----------------
aeubanks wrote:
I'd go even further and say something like "this is likely broken profile data"
https://github.com/llvm/llvm-project/pull/69513
More information about the llvm-commits
mailing list