diff options
Diffstat (limited to 'llvm/lib/ObjectYAML')
| -rw-r--r-- | llvm/lib/ObjectYAML/ELFEmitter.cpp | 18 | ||||
| -rw-r--r-- | llvm/lib/ObjectYAML/ELFYAML.cpp | 4 | 
2 files changed, 17 insertions, 5 deletions
| diff --git a/llvm/lib/ObjectYAML/ELFEmitter.cpp b/llvm/lib/ObjectYAML/ELFEmitter.cpp index 8b75fbe..8530785 100644 --- a/llvm/lib/ObjectYAML/ELFEmitter.cpp +++ b/llvm/lib/ObjectYAML/ELFEmitter.cpp @@ -1465,13 +1465,19 @@ void ELFState<ELFT>::writeSectionContent(    for (const auto &[Idx, E] : llvm::enumerate(*Section.Entries)) {      // Write version and feature values.      if (Section.Type == llvm::ELF::SHT_LLVM_BB_ADDR_MAP) { -      if (E.Version > 4) +      if (E.Version > 5)          WithColor::warning() << "unsupported SHT_LLVM_BB_ADDR_MAP version: "                               << static_cast<int>(E.Version)                               << "; encoding using the most recent version";        CBA.write(E.Version); -      CBA.write(E.Feature); -      SHeader.sh_size += 2; +      SHeader.sh_size += 1; +      if (E.Version < 5) { +        CBA.write(static_cast<uint8_t>(E.Feature)); +        SHeader.sh_size += 1; +      } else { +        CBA.write<uint16_t>(E.Feature, ELFT::Endianness); +        SHeader.sh_size += 2; +      }      }      auto FeatureOrErr = llvm::object::BBAddrMap::Features::decode(E.Feature);      bool MultiBBRangeFeatureEnabled = false; @@ -1556,11 +1562,15 @@ void ELFState<ELFT>::writeSectionContent(      for (const auto &PGOBBE : PGOBBEntries) {        if (PGOBBE.BBFreq)          SHeader.sh_size += CBA.writeULEB128(*PGOBBE.BBFreq); +      if (FeatureOrErr->PostLinkCfg || PGOBBE.PostLinkBBFreq.has_value()) +        SHeader.sh_size += CBA.writeULEB128(PGOBBE.PostLinkBBFreq.value_or(0));        if (PGOBBE.Successors) {          SHeader.sh_size += CBA.writeULEB128(PGOBBE.Successors->size()); -        for (const auto &[ID, BrProb] : *PGOBBE.Successors) { +        for (const auto &[ID, BrProb, PostLinkBrFreq] : *PGOBBE.Successors) {            SHeader.sh_size += CBA.writeULEB128(ID);            SHeader.sh_size += CBA.writeULEB128(BrProb); +          if (FeatureOrErr->PostLinkCfg || PostLinkBrFreq.has_value()) +            SHeader.sh_size += CBA.writeULEB128(PostLinkBrFreq.value_or(0));          }        }      } diff --git a/llvm/lib/ObjectYAML/ELFYAML.cpp b/llvm/lib/ObjectYAML/ELFYAML.cpp index f8a84b0..e5e5fc2 100644 --- a/llvm/lib/ObjectYAML/ELFYAML.cpp +++ b/llvm/lib/ObjectYAML/ELFYAML.cpp @@ -1886,7 +1886,7 @@ void MappingTraits<ELFYAML::BBAddrMapEntry>::mapping(      IO &IO, ELFYAML::BBAddrMapEntry &E) {    assert(IO.getContext() && "The IO context is not initialized");    IO.mapRequired("Version", E.Version); -  IO.mapOptional("Feature", E.Feature, Hex8(0)); +  IO.mapOptional("Feature", E.Feature, Hex16(0));    IO.mapOptional("NumBBRanges", E.NumBBRanges);    IO.mapOptional("BBRanges", E.BBRanges);  } @@ -1920,6 +1920,7 @@ void MappingTraits<ELFYAML::PGOAnalysisMapEntry::PGOBBEntry>::mapping(      IO &IO, ELFYAML::PGOAnalysisMapEntry::PGOBBEntry &E) {    assert(IO.getContext() && "The IO context is not initialized");    IO.mapOptional("BBFreq", E.BBFreq); +  IO.mapOptional("PostLinkBBFreq", E.PostLinkBBFreq);    IO.mapOptional("Successors", E.Successors);  } @@ -1929,6 +1930,7 @@ void MappingTraits<ELFYAML::PGOAnalysisMapEntry::PGOBBEntry::SuccessorEntry>::    assert(IO.getContext() && "The IO context is not initialized");    IO.mapRequired("ID", E.ID);    IO.mapRequired("BrProb", E.BrProb); +  IO.mapOptional("PostLinkBrFreq", E.PostLinkBrFreq);  }  void MappingTraits<ELFYAML::GnuHashHeader>::mapping(IO &IO, | 
