[InstrProf][NFC] Do not assume size of counter type
authorEllis Hoag <ellis.sparky.hoag@gmail.com>
Wed, 29 Dec 2021 21:36:28 +0000 (13:36 -0800)
committerEllis Hoag <ellis.sparky.hoag@gmail.com>
Fri, 14 Jan 2022 19:29:11 +0000 (11:29 -0800)
commitf21473752bd6ef85a4da5d51948ce21f7226f81b
tree4ab4401bd77b7b60d46bfcd7976329505d4b151e
parentacb8de565eaa2638d18362085085deb4628435b4
[InstrProf][NFC] Do not assume size of counter type

Existing code tended to assume that counters had type `uint64_t` and
computed size from the number of counters. Fix this code to directly
compute the counters size in number of bytes where possible. When the
number of counters is needed, use `__llvm_profile_counter_entry_size()`
or `getCounterTypeSize()`. In a later diff these functions will depend
on the profile mode.

Change the meaning of `DataSize` and `CountersSize` to make them more clear.
* `DataSize` (`CountersSize`) - the size of the data (counter) section in bytes.
* `NumData` (`NumCounters`) - the number of data (counter) entries.

Reviewed By: kyulee

Differential Revision: https://reviews.llvm.org/D116179
18 files changed:
compiler-rt/include/profile/InstrProfData.inc
compiler-rt/lib/profile/InstrProfiling.c
compiler-rt/lib/profile/InstrProfiling.h
compiler-rt/lib/profile/InstrProfilingBuffer.c
compiler-rt/lib/profile/InstrProfilingFile.c
compiler-rt/lib/profile/InstrProfilingInternal.h
compiler-rt/lib/profile/InstrProfilingMerge.c
compiler-rt/lib/profile/InstrProfilingPlatformDarwin.c
compiler-rt/lib/profile/InstrProfilingPlatformFuchsia.c
compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
compiler-rt/lib/profile/InstrProfilingPlatformOther.c
compiler-rt/lib/profile/InstrProfilingPlatformWindows.c
compiler-rt/lib/profile/InstrProfilingWriter.c
compiler-rt/test/profile/instrprof-write-buffer-internal.c
llvm/include/llvm/ProfileData/InstrProfData.inc
llvm/include/llvm/ProfileData/InstrProfReader.h
llvm/lib/ProfileData/InstrProfReader.cpp
llvm/test/tools/llvm-profdata/malformed-ptr-to-counter-array.test