[llvm] 8608209 - [ObjectYAML] Make BBAddrMap encoder diagnostics format-neutral (#202524)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 15 00:16:05 PDT 2026
Author: Haohai Wen
Date: 2026-06-15T15:16:00+08:00
New Revision: 860820992e2818cf3ad53eebaca1f479b6ab9237
URL: https://github.com/llvm/llvm-project/commit/860820992e2818cf3ad53eebaca1f479b6ab9237
DIFF: https://github.com/llvm/llvm-project/commit/860820992e2818cf3ad53eebaca1f479b6ab9237.diff
LOG: [ObjectYAML] Make BBAddrMap encoder diagnostics format-neutral (#202524)
In preparation for sharing the yaml2obj BBAddrMap encoder with COFF.
1. Drop the now-dead `Section.Type == SHT_LLVM_BB_ADDR_MAP` guards (#146186).
2. Reword the two warnings that will move into the shared helper.
3. Fix a "PBOBBEntries" -> "PGOBBEntries" typo.
Added:
Modified:
llvm/lib/ObjectYAML/ELFEmitter.cpp
llvm/test/tools/yaml2obj/ELF/bb-addr-map.yaml
Removed:
################################################################################
diff --git a/llvm/lib/ObjectYAML/ELFEmitter.cpp b/llvm/lib/ObjectYAML/ELFEmitter.cpp
index f4552f0a8f49b..4d423e71e959e 100644
--- a/llvm/lib/ObjectYAML/ELFEmitter.cpp
+++ b/llvm/lib/ObjectYAML/ELFEmitter.cpp
@@ -1464,20 +1464,18 @@ 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 > 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);
+ if (E.Version > 5)
+ WithColor::warning() << "unsupported BB address map version: "
+ << static_cast<int>(E.Version)
+ << "; encoding using the most recent version";
+ CBA.write(E.Version);
+ SHeader.sh_size += 1;
+ if (E.Version < 5) {
+ CBA.write(static_cast<uint8_t>(E.Feature));
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;
- }
+ } else {
+ CBA.write<uint16_t>(E.Feature, ELFT::Endianness);
+ SHeader.sh_size += 2;
}
auto FeatureOrErr = llvm::object::BBAddrMap::Features::decode(E.Feature);
if (!FeatureOrErr) {
@@ -1519,7 +1517,7 @@ void ELFState<ELFT>::writeSectionContent(
continue;
for (const BBAddrMapYAML::BBAddrMapEntry::BBEntry &BBE : *BBR.BBEntries) {
++TotalNumBlocks;
- if (Section.Type == llvm::ELF::SHT_LLVM_BB_ADDR_MAP && E.Version > 1)
+ if (E.Version > 1)
SHeader.sh_size += CBA.writeULEB128(BBE.ID);
SHeader.sh_size += CBA.writeULEB128(BBE.AddressOffset);
if (EmitCallsiteEndOffsets) {
@@ -1553,8 +1551,8 @@ void ELFState<ELFT>::writeSectionContent(
const auto &PGOBBEntries = PGOEntry.PGOBBEntries.value();
if (TotalNumBlocks != PGOBBEntries.size()) {
- WithColor::warning() << "PBOBBEntries must be the same length as "
- "BBEntries in SHT_LLVM_BB_ADDR_MAP.\n"
+ WithColor::warning() << "PGOBBEntries must be the same length as "
+ "BBEntries in the BB address map.\n"
<< "Mismatch on function with address: "
<< E.getFunctionAddress();
continue;
diff --git a/llvm/test/tools/yaml2obj/ELF/bb-addr-map.yaml b/llvm/test/tools/yaml2obj/ELF/bb-addr-map.yaml
index 05d77d67e4468..2b2fd43b243d9 100644
--- a/llvm/test/tools/yaml2obj/ELF/bb-addr-map.yaml
+++ b/llvm/test/tools/yaml2obj/ELF/bb-addr-map.yaml
@@ -220,7 +220,7 @@ Sections:
## Check that yaml2obj generates a warning when we use unsupported versions.
# RUN: yaml2obj --docnum=3 %s 2>&1 | FileCheck %s --check-prefix=INVALID-VERSION
-# INVALID-VERSION: warning: unsupported SHT_LLVM_BB_ADDR_MAP version: 6; encoding using the most recent version
+# INVALID-VERSION: warning: unsupported BB address map version: 6; encoding using the most recent version
--- !ELF
FileHeader:
More information about the llvm-commits
mailing list