Skip to content

Commit a676232

Browse files
committed
[SHT_LLVM_BB_ADDR_MAP] Drop support for versions 1 and 0 (SHT_LLVM_BB_ADDR_MAP_V0).
1 parent f1a4bb6 commit a676232

File tree

10 files changed

+54
-85
lines changed

10 files changed

+54
-85
lines changed

llvm/docs/Extensions.rst

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -430,27 +430,6 @@ Example:
430430
.uleb128 .LBB_END0_1-.LBB0_1 # BB_1 size
431431
.byte y # BB_1 metadata
432432
433-
Version 0: basic block address offsets are computed relative to the function
434-
address. This uses the unversioned ``SHT_LLVM_BB_ADDR_MAP_V0`` section type and
435-
is semantically equivalent to using ``SHT_LLVM_BB_ADDR_MAP`` with a zero
436-
version field.
437-
438-
Example:
439-
440-
.. code-block:: gas
441-
442-
.section ".llvm_bb_addr_map","",@llvm_bb_addr_map_v0
443-
.quad .Lfunc_begin0 # address of the function
444-
.byte 2 # number of basic blocks
445-
# BB record for BB_0
446-
.uleb128 .Lfunc_beign0-.Lfunc_begin0 # BB_0 offset relative to the function entry (always zero)
447-
.uleb128 .LBB_END0_0-.Lfunc_begin0 # BB_0 size
448-
.byte x # BB_0 metadata
449-
# BB record for BB_1
450-
.uleb128 .LBB0_1-.Lfunc_begin0 # BB_1 offset relative to the function entry
451-
.uleb128 .LBB_END0_1-.LBB0_1 # BB_1 size
452-
.byte y # BB_1 metadata
453-
454433
PGO Analysis Map
455434
""""""""""""""""
456435

llvm/docs/ReleaseNotes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ Changes to the LLVM tools
273273
* In llvm-objcopy/llvm-strip's ELF port, `--discard-locals` and `--discard-all` now allow and preserve symbols referenced by relocations.
274274
([#47468](https://github.com/llvm/llvm-project/issues/47468))
275275
* llvm-addr2line now supports a `+` prefix when specifying an address.
276+
* Support for `SHT_LLVM_BB_ADDR_MAP` versions 1 and lower is dropped.
276277

277278
Changes to LLDB
278279
---------------------------------

llvm/include/llvm/BinaryFormat/ELF.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,9 +1153,7 @@ enum : unsigned {
11531153
SHT_LLVM_SYMPART = 0x6fff4c05, // Symbol partition specification.
11541154
SHT_LLVM_PART_EHDR = 0x6fff4c06, // ELF header for loadable partition.
11551155
SHT_LLVM_PART_PHDR = 0x6fff4c07, // Phdrs for loadable partition.
1156-
SHT_LLVM_BB_ADDR_MAP_V0 =
1157-
0x6fff4c08, // LLVM Basic Block Address Map (old version kept for
1158-
// backward-compatibility).
1156+
// SHT_LLVM_BB_ADDR_MAP_V0 = 0x6fff4c08, // Do not use.
11591157
SHT_LLVM_CALL_GRAPH_PROFILE = 0x6fff4c09, // LLVM Call Graph Profile.
11601158
SHT_LLVM_BB_ADDR_MAP = 0x6fff4c0a, // LLVM Basic Block Address Map.
11611159
SHT_LLVM_OFFLOADING = 0x6fff4c0b, // LLVM device offloading data.

llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,16 +1483,13 @@ void AsmPrinter::emitBBAddrMapSection(const MachineFunction &MF) {
14831483
}
14841484

14851485
if (!Features.OmitBBEntries) {
1486-
// TODO: Remove this check when version 1 is deprecated.
1487-
if (BBAddrMapVersion > 1) {
1488-
OutStreamer->AddComment("BB id");
1489-
// Emit the BB ID for this basic block.
1490-
// We only emit BaseID since CloneID is unset for
1491-
// -basic-block-adress-map.
1492-
// TODO: Emit the full BBID when labels and sections can be mixed
1493-
// together.
1494-
OutStreamer->emitULEB128IntValue(MBB.getBBID()->BaseID);
1495-
}
1486+
OutStreamer->AddComment("BB id");
1487+
// Emit the BB ID for this basic block.
1488+
// We only emit BaseID since CloneID is unset for
1489+
// -basic-block-adress-map.
1490+
// TODO: Emit the full BBID when labels and sections can be mixed
1491+
// together.
1492+
OutStreamer->emitULEB128IntValue(MBB.getBBID()->BaseID);
14961493
// Emit the basic block offset relative to the end of the previous block.
14971494
// This is zero unless the block is padded due to alignment.
14981495
emitLabelDifferenceAsULEB128(MBBSymbol, PrevMBBEndSymbol);

llvm/lib/MC/MCSectionELF.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,6 @@ void MCSectionELF::printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
170170
OS << "llvm_sympart";
171171
else if (Type == ELF::SHT_LLVM_BB_ADDR_MAP)
172172
OS << "llvm_bb_addr_map";
173-
else if (Type == ELF::SHT_LLVM_BB_ADDR_MAP_V0)
174-
OS << "llvm_bb_addr_map_v0";
175173
else if (Type == ELF::SHT_LLVM_OFFLOADING)
176174
OS << "llvm_offloading";
177175
else if (Type == ELF::SHT_LLVM_LTO)

llvm/lib/Object/ELF.cpp

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,6 @@ StringRef llvm::object::getELFSectionTypeName(uint32_t Machine, unsigned Type) {
317317
STRINGIFY_ENUM_CASE(ELF, SHT_LLVM_SYMPART);
318318
STRINGIFY_ENUM_CASE(ELF, SHT_LLVM_PART_EHDR);
319319
STRINGIFY_ENUM_CASE(ELF, SHT_LLVM_PART_PHDR);
320-
STRINGIFY_ENUM_CASE(ELF, SHT_LLVM_BB_ADDR_MAP_V0);
321320
STRINGIFY_ENUM_CASE(ELF, SHT_LLVM_BB_ADDR_MAP);
322321
STRINGIFY_ENUM_CASE(ELF, SHT_LLVM_OFFLOADING);
323322
STRINGIFY_ENUM_CASE(ELF, SHT_LLVM_LTO);
@@ -833,33 +832,27 @@ decodeBBAddrMapImpl(const ELFFile<ELFT> &EF,
833832
BBAddrMap::Features FeatEnable{};
834833
while (!ULEBSizeErr && !MetadataDecodeErr && Cur &&
835834
Cur.tell() < Content.size()) {
836-
if (Sec.sh_type == ELF::SHT_LLVM_BB_ADDR_MAP) {
837-
Version = Data.getU8(Cur);
838-
if (!Cur)
839-
break;
840-
if (Version > 3)
841-
return createError("unsupported SHT_LLVM_BB_ADDR_MAP version: " +
842-
Twine(static_cast<int>(Version)));
843-
Feature = Data.getU8(Cur); // Feature byte
844-
if (!Cur)
845-
break;
846-
auto FeatEnableOrErr = BBAddrMap::Features::decode(Feature);
847-
if (!FeatEnableOrErr)
848-
return FeatEnableOrErr.takeError();
849-
FeatEnable = *FeatEnableOrErr;
850-
if (FeatEnable.hasPGOAnalysis() && Version < 2)
851-
return createError(
852-
"version should be >= 2 for SHT_LLVM_BB_ADDR_MAP when "
853-
"PGO features are enabled: version = " +
854-
Twine(static_cast<int>(Version)) +
855-
" feature = " + Twine(static_cast<int>(Feature)));
856-
if (FeatEnable.CallsiteOffsets && Version < 3)
857-
return createError(
858-
"version should be >= 3 for SHT_LLVM_BB_ADDR_MAP when "
859-
"callsite offsets feature is enabled: version = " +
860-
Twine(static_cast<int>(Version)) +
861-
" feature = " + Twine(static_cast<int>(Feature)));
862-
}
835+
Version = Data.getU8(Cur);
836+
if (!Cur)
837+
break;
838+
if (Version < 2)
839+
return createError("deprecated SHT_LLVM_BB_ADDR_MAP version: " +
840+
Twine(static_cast<int>(Version)));
841+
if (Version > 3)
842+
return createError("unsupported SHT_LLVM_BB_ADDR_MAP version: " +
843+
Twine(static_cast<int>(Version)));
844+
Feature = Data.getU8(Cur); // Feature byte
845+
if (!Cur)
846+
break;
847+
auto FeatEnableOrErr = BBAddrMap::Features::decode(Feature);
848+
if (!FeatEnableOrErr)
849+
return FeatEnableOrErr.takeError();
850+
FeatEnable = *FeatEnableOrErr;
851+
if (FeatEnable.CallsiteOffsets && Version < 3)
852+
return createError("version should be >= 3 for SHT_LLVM_BB_ADDR_MAP when "
853+
"callsite offsets feature is enabled: version = " +
854+
Twine(static_cast<int>(Version)) +
855+
" feature = " + Twine(static_cast<int>(Feature)));
863856
uint32_t NumBlocksInBBRange = 0;
864857
uint32_t NumBBRanges = 1;
865858
typename ELFFile<ELFT>::uintX_t RangeBaseAddress = 0;

llvm/lib/Object/ELFObjectFile.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -904,8 +904,7 @@ Expected<std::vector<BBAddrMap>> static readBBAddrMapImpl(
904904

905905
const auto &Sections = cantFail(EF.sections());
906906
auto IsMatch = [&](const Elf_Shdr &Sec) -> Expected<bool> {
907-
if (Sec.sh_type != ELF::SHT_LLVM_BB_ADDR_MAP &&
908-
Sec.sh_type != ELF::SHT_LLVM_BB_ADDR_MAP_V0)
907+
if (Sec.sh_type != ELF::SHT_LLVM_BB_ADDR_MAP)
909908
return false;
910909
if (!TextSectionIndex)
911910
return true;

llvm/lib/ObjectYAML/ELFYAML.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,6 @@ void ScalarEnumerationTraits<ELFYAML::ELF_SHT>::enumeration(
720720
ECase(SHT_LLVM_SYMPART);
721721
ECase(SHT_LLVM_PART_EHDR);
722722
ECase(SHT_LLVM_PART_PHDR);
723-
ECase(SHT_LLVM_BB_ADDR_MAP_V0);
724723
ECase(SHT_LLVM_BB_ADDR_MAP);
725724
ECase(SHT_LLVM_OFFLOADING);
726725
ECase(SHT_LLVM_LTO);

llvm/test/tools/llvm-objdump/X86/elf-bbaddrmap-disassemble-symbolize-operands.yaml

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
# ATT-NEXT: <BB0>:
3434
# ATT-NEXT: pushq %rax
3535
# ATT-NEXT: movl %edx, %eax
36-
# ATT-NEXT: je <BB2>
37-
# ATT-NEXT: <BB1>:
38-
# ATT-NEXT: xorl %esi, %esi
36+
# ATT-NEXT: je <BB4>
3937
# ATT-NEXT: <BB2>:
38+
# ATT-NEXT: xorl %esi, %esi
39+
# ATT-NEXT: <BB4>:
4040
# ATT-NEXT: callq <bar>
4141
# ATT-NEXT: retq
4242
# ATT: <foo.cold>:
@@ -60,10 +60,10 @@
6060
# INTEL-NEXT: <BB0>:
6161
# INTEL-NEXT: push rax
6262
# INTEL-NEXT: mov eax, edx
63-
# INTEL-NEXT: je <BB2>
64-
# INTEL-NEXT: <BB1>:
65-
# INTEL-NEXT: xor esi, esi
63+
# INTEL-NEXT: je <BB4>
6664
# INTEL-NEXT: <BB2>:
65+
# INTEL-NEXT: xor esi, esi
66+
# INTEL-NEXT: <BB4>:
6767
# INTEL-NEXT: call <bar>
6868
# INTEL-NEXT: ret
6969
# INTEL: <foo.cold>:
@@ -139,17 +139,20 @@ Sections:
139139
Type: SHT_LLVM_BB_ADDR_MAP
140140
Link: .text.bar
141141
Entries:
142-
- Version: 1
142+
- Version: 2
143143
BBRanges:
144144
- BaseAddress: 0x5000
145145
BBEntries:
146-
- AddressOffset: 0x0
146+
- ID: 0
147+
AddressOffset: 0x0
147148
Size: 0x1
148149
Metadata: 0x1
149-
- AddressOffset: 0x4
150+
- ID: 2
151+
AddressOffset: 0x4
150152
Size: 0x2
151153
Metadata: 0x0
152-
- AddressOffset: 0x0
154+
- ID: 4
155+
AddressOffset: 0x0
153156
Size: 0x6
154157
Metadata: 0x0
155158

@@ -230,17 +233,20 @@ Sections:
230233
AddressOffset: 0x0
231234
Size: 0x1
232235
Metadata: 0x2
233-
- Version: 1
236+
- Version: 2
234237
BBRanges:
235238
- BaseAddress: 0x5000
236239
BBEntries:
237-
- AddressOffset: 0x0
240+
- ID: 0
241+
AddressOffset: 0x0
238242
Size: 0x1
239243
Metadata: 0x1
240-
- AddressOffset: 0x4
244+
- ID: 2
245+
AddressOffset: 0x4
241246
Size: 0x2
242247
Metadata: 0x0
243-
- AddressOffset: 0x0
248+
- ID: 4
249+
AddressOffset: 0x0
244250
Size: 0x6
245251
Metadata: 0x0
246252

llvm/unittests/Object/ELFObjectFileTest.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ TEST(ELFObjectFileTest, ReadBBAddrMap) {
737737
Type: SHT_LLVM_BB_ADDR_MAP
738738
Link: 2
739739
Entries:
740-
- Version: 1
740+
- Version: 2
741741
BBRanges:
742742
- BaseAddress: 0x33333
743743
BBEntries:
@@ -904,7 +904,7 @@ TEST(ELFObjectFileTest, InvalidDecodePGOAnalysisMap) {
904904
SmallString<128> UnsupportedLowVersionYamlString(CommonYamlString);
905905
UnsupportedLowVersionYamlString += R"(
906906
- Version: 1
907-
Feature: 0x4
907+
Feature: 0x0
908908
BBRanges:
909909
- BBEntries:
910910
- AddressOffset: 0x0
@@ -915,8 +915,7 @@ TEST(ELFObjectFileTest, InvalidDecodePGOAnalysisMap) {
915915
{
916916
SCOPED_TRACE("unsupported version");
917917
DoCheck(UnsupportedLowVersionYamlString,
918-
"version should be >= 2 for SHT_LLVM_BB_ADDR_MAP when PGO features "
919-
"are enabled: version = 1 feature = 4");
918+
"deprecated SHT_LLVM_BB_ADDR_MAP version: 1");
920919
}
921920

922921
// Check that we fail when function entry count is enabled but not provided.

0 commit comments

Comments
 (0)