1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 04:02:41 +01:00

[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
This commit is contained in:
Rahman Lavaee 2021-02-22 17:50:14 -08:00
parent f4588e33e1
commit d556b3aaf8
4 changed files with 5 additions and 5 deletions

View File

@ -1359,7 +1359,7 @@ void ELFState<ELFT>::writeSectionContent(
// 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). This
// is overriden by the 'NumBlocks' YAML field if specified.
// is overridden by the 'NumBlocks' YAML field when specified.
uint32_t NumBlocks =
E.NumBlocks.getValueOr(E.BBEntries ? E.BBEntries->size() : 0);
SHeader.sh_size += sizeof(uintX_t) + CBA.writeULEB128(NumBlocks);

View File

@ -1665,8 +1665,8 @@ void MappingTraits<ELFYAML::BBAddrMapEntry>::mapping(
IO &IO, ELFYAML::BBAddrMapEntry &E) {
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);
IO.mapOptional("BBEntries", E.BBEntries);
}
void MappingTraits<ELFYAML::BBAddrMapEntry::BBEntry>::mapping(

View File

@ -130,8 +130,8 @@ Sections:
- Address: 0x20
## Check that obj2yaml uses the "Content" tag to describe an .llvm_bb_addr_map section
## when it can't extract the entries, for example, when section is truncated, or when
## an invalid NumBlocks field is specified.
## when it can't extract the entries, for example, when the section is truncated, or
## when an invalid 'NumBlocks' field is specified.
# RUN: yaml2obj --docnum=1 -DSIZE=0x8 %s -o %t4
# RUN: obj2yaml %t4 | FileCheck %s --check-prefixes=TRUNCATED,INVALID

View File

@ -861,7 +861,7 @@ ELFDumper<ELFT>::dumpBBAddrMapSection(const Elf_Shdr *Shdr) {
uint64_t Metadata = Data.getULEB128(Cur);
BBEntries.push_back({Offset, Size, Metadata});
}
Entries.push_back({Address, /* NumBlocks */ {}, BBEntries});
Entries.push_back({Address, /*NumBlocks=*/{}, BBEntries});
}
if (!Cur) {