[llvm-profdata] Fixed various issue with Sample Profile Reader
authorWilliam Huang <williamjhuang@google.com>
Wed, 12 Apr 2023 00:49:05 +0000 (00:49 +0000)
committerWilliam Huang <williamjhuang@google.com>
Thu, 13 Apr 2023 21:31:26 +0000 (21:31 +0000)
commit30037b7a6ad81cdbf06e216204275150e62aec7c
treee2fe0d498f3432ead83ea4165b0e1dd6d0b81338
parent6f8360a0e15f3affe3f711130c693059930bc317
[llvm-profdata] Fixed various issue with Sample Profile Reader

Fixed various undefind behaviors with current Sample Profile Reader when reading unusual input. Furthermore, add the following rule on allowing multiple name table sections (current Reader has conflicted code handling such case):

When a new name table section is read (in the order sections are read), the names in the previous name table are cleared. Any subsequent sections referring to function names will index into the most recent read name table.

Also changed name table index to uint64_t to be consistent since there's a mix of using uint32_t and uint64_t.

Reviewed By: snehasish, huangjd

Differential Revision: https://reviews.llvm.org/D146182
llvm/include/llvm/ProfileData/SampleProf.h
llvm/include/llvm/ProfileData/SampleProfReader.h
llvm/lib/ProfileData/SampleProfReader.cpp