diff options
author | Rahman Lavaee <rahmanl@google.com> | 2021-02-16 18:43:56 -0800 |
---|---|---|
committer | Rahman Lavaee <rahmanl@google.com> | 2021-02-17 15:45:13 -0800 |
commit | 0252e6ead192f7c61e5a02ceea420bee28a2f251 (patch) | |
tree | d69dc439fda5c86ff6dd9f5738d24855ecdbff23 /llvm/lib | |
parent | 0d4534237de38fcf1b2a71bcb0f74cb5675fe7e1 (diff) | |
download | llvm-0252e6ead192f7c61e5a02ceea420bee28a2f251.zip llvm-0252e6ead192f7c61e5a02ceea420bee28a2f251.tar.gz llvm-0252e6ead192f7c61e5a02ceea420bee28a2f251.tar.bz2 |
[obj2yaml,yaml2obj] Add NumBlocks to the BBAddrMapEntry yaml field.
As discussed in D95511, this allows us to encode invalid BBAddrMap
sections to be used in more rigorous testing.
Reviewed By: jhenderson
Differential Revision: https://reviews.llvm.org/D96831
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/ObjectYAML/ELFEmitter.cpp | 10 | ||||
-rw-r--r-- | llvm/lib/ObjectYAML/ELFYAML.cpp | 1 |
2 files changed, 7 insertions, 4 deletions
diff --git a/llvm/lib/ObjectYAML/ELFEmitter.cpp b/llvm/lib/ObjectYAML/ELFEmitter.cpp index 089ef8e8..a9ff25c 100644 --- a/llvm/lib/ObjectYAML/ELFEmitter.cpp +++ b/llvm/lib/ObjectYAML/ELFEmitter.cpp @@ -1358,12 +1358,14 @@ void ELFState<ELFT>::writeSectionContent( for (const ELFYAML::BBAddrMapEntry &E : *Section.Entries) { // Write the address of the function. CBA.write<uintX_t>(E.Address, ELFT::TargetEndianness); - // Write number of BBEntries (number of basic blocks in the function). - size_t NumBlocks = E.BBEntries ? E.BBEntries->size() : 0; + // Write number of BBEntries (number of basic blocks in the function). This + // is overriden by the 'NumBlocks' YAML field if specified. + uint32_t NumBlocks = + E.NumBlocks.getValueOr(E.BBEntries ? E.BBEntries->size() : 0); SHeader.sh_size += sizeof(uintX_t) + CBA.writeULEB128(NumBlocks); - if (!NumBlocks) - continue; // Write all BBEntries. + if (!E.BBEntries) + continue; for (const ELFYAML::BBAddrMapEntry::BBEntry &BBE : *E.BBEntries) SHeader.sh_size += CBA.writeULEB128(BBE.AddressOffset) + CBA.writeULEB128(BBE.Size) + diff --git a/llvm/lib/ObjectYAML/ELFYAML.cpp b/llvm/lib/ObjectYAML/ELFYAML.cpp index bde91c5..1eedc64 100644 --- a/llvm/lib/ObjectYAML/ELFYAML.cpp +++ b/llvm/lib/ObjectYAML/ELFYAML.cpp @@ -1665,6 +1665,7 @@ void MappingTraits<ELFYAML::BBAddrMapEntry>::mapping( assert(IO.getContext() && "The IO context is not initialized"); IO.mapOptional("Address", E.Address, Hex64(0)); IO.mapOptional("BBEntries", E.BBEntries); + IO.mapOptional("NumBlocks", E.NumBlocks); } void MappingTraits<ELFYAML::BBAddrMapEntry::BBEntry>::mapping( |