[NFC][SampleFDO] Preparation to support multiple sections with the same type
authorWei Mi <wmi@google.com>
Mon, 14 Dec 2020 22:49:20 +0000 (14:49 -0800)
committerWei Mi <wmi@google.com>
Thu, 17 Dec 2020 06:28:45 +0000 (22:28 -0800)
commita906e3eccd1ed149ffc8bdf2540c7cff4171e3bd
tree2188e363fe0ce66f39e9c5f8a1750d081ec66f0f
parent39584ae5b5cbc817d19499b003d4eaba259c31b5
[NFC][SampleFDO] Preparation to support multiple sections with the same type
in ExtBinary format.

Currently ExtBinary format doesn't support multiple sections with the same type
in the profile. We add the support in this patch. Previously we use the section
type to identify a section uniquely. Now we introduces a LayoutIndex in the
SecHdrTableEntry and use the LayoutIndex to locate the target section. The
allocations of NameTable and FuncOffsetTable are adjusted accordingly.

Currently it works as a NFC because it won't change anything for current layout.
The test for multiple sections support will be included in another patch where a
new type of profile containing multiple sections with the same type is
introduced.

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