-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[SHT_LLVM_BB_ADDR_MAP] Deprecate versions 1 and 0 (SHT_LLVM_BB_ADDR_MAP_V0). #146186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rlavaee
wants to merge
1
commit into
llvm:main
Choose a base branch
from
rlavaee:bbaddrmap
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-objectyaml @llvm/pr-subscribers-mc Author: Rahman Lavaee (rlavaee) ChangesVersion 2 was added more than two years ago (6015a04). So it should be safe to deprecate lower versions. Full diff: https://github.com/llvm/llvm-project/pull/146186.diff 9 Files Affected:
diff --git a/llvm/docs/Extensions.rst b/llvm/docs/Extensions.rst
index ea267842cdc35..f92eac3209c21 100644
--- a/llvm/docs/Extensions.rst
+++ b/llvm/docs/Extensions.rst
@@ -430,27 +430,6 @@ Example:
.uleb128 .LBB_END0_1-.LBB0_1 # BB_1 size
.byte y # BB_1 metadata
-Version 0: basic block address offsets are computed relative to the function
-address. This uses the unversioned ``SHT_LLVM_BB_ADDR_MAP_V0`` section type and
-is semantically equivalent to using ``SHT_LLVM_BB_ADDR_MAP`` with a zero
-version field.
-
-Example:
-
-.. code-block:: gas
-
- .section ".llvm_bb_addr_map","",@llvm_bb_addr_map_v0
- .quad .Lfunc_begin0 # address of the function
- .byte 2 # number of basic blocks
- # BB record for BB_0
- .uleb128 .Lfunc_beign0-.Lfunc_begin0 # BB_0 offset relative to the function entry (always zero)
- .uleb128 .LBB_END0_0-.Lfunc_begin0 # BB_0 size
- .byte x # BB_0 metadata
- # BB record for BB_1
- .uleb128 .LBB0_1-.Lfunc_begin0 # BB_1 offset relative to the function entry
- .uleb128 .LBB_END0_1-.LBB0_1 # BB_1 size
- .byte y # BB_1 metadata
-
PGO Analysis Map
""""""""""""""""
diff --git a/llvm/include/llvm/BinaryFormat/ELF.h b/llvm/include/llvm/BinaryFormat/ELF.h
index f5f236cf98064..7771723dc0d3f 100644
--- a/llvm/include/llvm/BinaryFormat/ELF.h
+++ b/llvm/include/llvm/BinaryFormat/ELF.h
@@ -1153,9 +1153,6 @@ enum : unsigned {
SHT_LLVM_SYMPART = 0x6fff4c05, // Symbol partition specification.
SHT_LLVM_PART_EHDR = 0x6fff4c06, // ELF header for loadable partition.
SHT_LLVM_PART_PHDR = 0x6fff4c07, // Phdrs for loadable partition.
- SHT_LLVM_BB_ADDR_MAP_V0 =
- 0x6fff4c08, // LLVM Basic Block Address Map (old version kept for
- // backward-compatibility).
SHT_LLVM_CALL_GRAPH_PROFILE = 0x6fff4c09, // LLVM Call Graph Profile.
SHT_LLVM_BB_ADDR_MAP = 0x6fff4c0a, // LLVM Basic Block Address Map.
SHT_LLVM_OFFLOADING = 0x6fff4c0b, // LLVM device offloading data.
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 754dba73673c2..07d9380a02c43 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1483,16 +1483,13 @@ void AsmPrinter::emitBBAddrMapSection(const MachineFunction &MF) {
}
if (!Features.OmitBBEntries) {
- // TODO: Remove this check when version 1 is deprecated.
- if (BBAddrMapVersion > 1) {
- OutStreamer->AddComment("BB id");
- // Emit the BB ID for this basic block.
- // We only emit BaseID since CloneID is unset for
- // -basic-block-adress-map.
- // TODO: Emit the full BBID when labels and sections can be mixed
- // together.
- OutStreamer->emitULEB128IntValue(MBB.getBBID()->BaseID);
- }
+ OutStreamer->AddComment("BB id");
+ // Emit the BB ID for this basic block.
+ // We only emit BaseID since CloneID is unset for
+ // -basic-block-adress-map.
+ // TODO: Emit the full BBID when labels and sections can be mixed
+ // together.
+ OutStreamer->emitULEB128IntValue(MBB.getBBID()->BaseID);
// Emit the basic block offset relative to the end of the previous block.
// This is zero unless the block is padded due to alignment.
emitLabelDifferenceAsULEB128(MBBSymbol, PrevMBBEndSymbol);
diff --git a/llvm/lib/MC/MCSectionELF.cpp b/llvm/lib/MC/MCSectionELF.cpp
index 181c4ff25d541..cc7cdf2fe4d1a 100644
--- a/llvm/lib/MC/MCSectionELF.cpp
+++ b/llvm/lib/MC/MCSectionELF.cpp
@@ -170,8 +170,6 @@ void MCSectionELF::printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
OS << "llvm_sympart";
else if (Type == ELF::SHT_LLVM_BB_ADDR_MAP)
OS << "llvm_bb_addr_map";
- else if (Type == ELF::SHT_LLVM_BB_ADDR_MAP_V0)
- OS << "llvm_bb_addr_map_v0";
else if (Type == ELF::SHT_LLVM_OFFLOADING)
OS << "llvm_offloading";
else if (Type == ELF::SHT_LLVM_LTO)
diff --git a/llvm/lib/Object/ELF.cpp b/llvm/lib/Object/ELF.cpp
index 6ee33d94ee861..2eba176fae296 100644
--- a/llvm/lib/Object/ELF.cpp
+++ b/llvm/lib/Object/ELF.cpp
@@ -317,7 +317,6 @@ StringRef llvm::object::getELFSectionTypeName(uint32_t Machine, unsigned Type) {
STRINGIFY_ENUM_CASE(ELF, SHT_LLVM_SYMPART);
STRINGIFY_ENUM_CASE(ELF, SHT_LLVM_PART_EHDR);
STRINGIFY_ENUM_CASE(ELF, SHT_LLVM_PART_PHDR);
- STRINGIFY_ENUM_CASE(ELF, SHT_LLVM_BB_ADDR_MAP_V0);
STRINGIFY_ENUM_CASE(ELF, SHT_LLVM_BB_ADDR_MAP);
STRINGIFY_ENUM_CASE(ELF, SHT_LLVM_OFFLOADING);
STRINGIFY_ENUM_CASE(ELF, SHT_LLVM_LTO);
@@ -833,33 +832,27 @@ decodeBBAddrMapImpl(const ELFFile<ELFT> &EF,
BBAddrMap::Features FeatEnable{};
while (!ULEBSizeErr && !MetadataDecodeErr && Cur &&
Cur.tell() < Content.size()) {
- if (Sec.sh_type == ELF::SHT_LLVM_BB_ADDR_MAP) {
- Version = Data.getU8(Cur);
- if (!Cur)
- break;
- if (Version > 3)
- return createError("unsupported SHT_LLVM_BB_ADDR_MAP version: " +
- Twine(static_cast<int>(Version)));
- Feature = Data.getU8(Cur); // Feature byte
- if (!Cur)
- break;
- auto FeatEnableOrErr = BBAddrMap::Features::decode(Feature);
- if (!FeatEnableOrErr)
- return FeatEnableOrErr.takeError();
- FeatEnable = *FeatEnableOrErr;
- if (FeatEnable.hasPGOAnalysis() && Version < 2)
- return createError(
- "version should be >= 2 for SHT_LLVM_BB_ADDR_MAP when "
- "PGO features are enabled: version = " +
- Twine(static_cast<int>(Version)) +
- " feature = " + Twine(static_cast<int>(Feature)));
- if (FeatEnable.CallsiteOffsets && Version < 3)
- return createError(
- "version should be >= 3 for SHT_LLVM_BB_ADDR_MAP when "
- "callsite offsets feature is enabled: version = " +
- Twine(static_cast<int>(Version)) +
- " feature = " + Twine(static_cast<int>(Feature)));
- }
+ Version = Data.getU8(Cur);
+ if (!Cur)
+ break;
+ if (Version < 2)
+ return createError("deprecated SHT_LLVM_BB_ADDR_MAP version: " +
+ Twine(static_cast<int>(Version)));
+ if (Version > 3)
+ return createError("unsupported SHT_LLVM_BB_ADDR_MAP version: " +
+ Twine(static_cast<int>(Version)));
+ Feature = Data.getU8(Cur); // Feature byte
+ if (!Cur)
+ break;
+ auto FeatEnableOrErr = BBAddrMap::Features::decode(Feature);
+ if (!FeatEnableOrErr)
+ return FeatEnableOrErr.takeError();
+ FeatEnable = *FeatEnableOrErr;
+ if (FeatEnable.CallsiteOffsets && Version < 3)
+ return createError("version should be >= 3 for SHT_LLVM_BB_ADDR_MAP when "
+ "callsite offsets feature is enabled: version = " +
+ Twine(static_cast<int>(Version)) +
+ " feature = " + Twine(static_cast<int>(Feature)));
uint32_t NumBlocksInBBRange = 0;
uint32_t NumBBRanges = 1;
typename ELFFile<ELFT>::uintX_t RangeBaseAddress = 0;
diff --git a/llvm/lib/Object/ELFObjectFile.cpp b/llvm/lib/Object/ELFObjectFile.cpp
index cce5c74aa4d1d..0e13d32bbe522 100644
--- a/llvm/lib/Object/ELFObjectFile.cpp
+++ b/llvm/lib/Object/ELFObjectFile.cpp
@@ -904,8 +904,7 @@ Expected<std::vector<BBAddrMap>> static readBBAddrMapImpl(
const auto &Sections = cantFail(EF.sections());
auto IsMatch = [&](const Elf_Shdr &Sec) -> Expected<bool> {
- if (Sec.sh_type != ELF::SHT_LLVM_BB_ADDR_MAP &&
- Sec.sh_type != ELF::SHT_LLVM_BB_ADDR_MAP_V0)
+ if (Sec.sh_type != ELF::SHT_LLVM_BB_ADDR_MAP)
return false;
if (!TextSectionIndex)
return true;
diff --git a/llvm/lib/ObjectYAML/ELFYAML.cpp b/llvm/lib/ObjectYAML/ELFYAML.cpp
index b28191730f018..970811f40f918 100644
--- a/llvm/lib/ObjectYAML/ELFYAML.cpp
+++ b/llvm/lib/ObjectYAML/ELFYAML.cpp
@@ -720,7 +720,6 @@ void ScalarEnumerationTraits<ELFYAML::ELF_SHT>::enumeration(
ECase(SHT_LLVM_SYMPART);
ECase(SHT_LLVM_PART_EHDR);
ECase(SHT_LLVM_PART_PHDR);
- ECase(SHT_LLVM_BB_ADDR_MAP_V0);
ECase(SHT_LLVM_BB_ADDR_MAP);
ECase(SHT_LLVM_OFFLOADING);
ECase(SHT_LLVM_LTO);
diff --git a/llvm/test/tools/llvm-objdump/X86/elf-bbaddrmap-disassemble-symbolize-operands.yaml b/llvm/test/tools/llvm-objdump/X86/elf-bbaddrmap-disassemble-symbolize-operands.yaml
index cc7faea67bed2..737e902f4023c 100644
--- a/llvm/test/tools/llvm-objdump/X86/elf-bbaddrmap-disassemble-symbolize-operands.yaml
+++ b/llvm/test/tools/llvm-objdump/X86/elf-bbaddrmap-disassemble-symbolize-operands.yaml
@@ -33,10 +33,10 @@
# ATT-NEXT: <BB0>:
# ATT-NEXT: pushq %rax
# ATT-NEXT: movl %edx, %eax
-# ATT-NEXT: je <BB2>
-# ATT-NEXT: <BB1>:
-# ATT-NEXT: xorl %esi, %esi
+# ATT-NEXT: je <BB4>
# ATT-NEXT: <BB2>:
+# ATT-NEXT: xorl %esi, %esi
+# ATT-NEXT: <BB4>:
# ATT-NEXT: callq <bar>
# ATT-NEXT: retq
# ATT: <foo.cold>:
@@ -60,10 +60,10 @@
# INTEL-NEXT: <BB0>:
# INTEL-NEXT: push rax
# INTEL-NEXT: mov eax, edx
-# INTEL-NEXT: je <BB2>
-# INTEL-NEXT: <BB1>:
-# INTEL-NEXT: xor esi, esi
+# INTEL-NEXT: je <BB4>
# INTEL-NEXT: <BB2>:
+# INTEL-NEXT: xor esi, esi
+# INTEL-NEXT: <BB4>:
# INTEL-NEXT: call <bar>
# INTEL-NEXT: ret
# INTEL: <foo.cold>:
@@ -139,17 +139,20 @@ Sections:
Type: SHT_LLVM_BB_ADDR_MAP
Link: .text.bar
Entries:
- - Version: 1
+ - Version: 2
BBRanges:
- BaseAddress: 0x5000
BBEntries:
- - AddressOffset: 0x0
+ - ID: 0
+ AddressOffset: 0x0
Size: 0x1
Metadata: 0x1
- - AddressOffset: 0x4
+ - ID: 2
+ AddressOffset: 0x4
Size: 0x2
Metadata: 0x0
- - AddressOffset: 0x0
+ - ID: 4
+ AddressOffset: 0x0
Size: 0x6
Metadata: 0x0
@@ -230,17 +233,20 @@ Sections:
AddressOffset: 0x0
Size: 0x1
Metadata: 0x2
- - Version: 1
+ - Version: 2
BBRanges:
- BaseAddress: 0x5000
BBEntries:
- - AddressOffset: 0x0
+ - ID: 0
+ AddressOffset: 0x0
Size: 0x1
Metadata: 0x1
- - AddressOffset: 0x4
+ - ID: 2
+ AddressOffset: 0x4
Size: 0x2
Metadata: 0x0
- - AddressOffset: 0x0
+ - ID: 4
+ AddressOffset: 0x0
Size: 0x6
Metadata: 0x0
diff --git a/llvm/unittests/Object/ELFObjectFileTest.cpp b/llvm/unittests/Object/ELFObjectFileTest.cpp
index 423f92ea07b39..10b7d2ed2e21d 100644
--- a/llvm/unittests/Object/ELFObjectFileTest.cpp
+++ b/llvm/unittests/Object/ELFObjectFileTest.cpp
@@ -737,7 +737,7 @@ TEST(ELFObjectFileTest, ReadBBAddrMap) {
Type: SHT_LLVM_BB_ADDR_MAP
Link: 2
Entries:
- - Version: 1
+ - Version: 2
BBRanges:
- BaseAddress: 0x33333
BBEntries:
@@ -904,7 +904,7 @@ TEST(ELFObjectFileTest, InvalidDecodePGOAnalysisMap) {
SmallString<128> UnsupportedLowVersionYamlString(CommonYamlString);
UnsupportedLowVersionYamlString += R"(
- Version: 1
- Feature: 0x4
+ Feature: 0x0
BBRanges:
- BBEntries:
- AddressOffset: 0x0
@@ -915,8 +915,7 @@ TEST(ELFObjectFileTest, InvalidDecodePGOAnalysisMap) {
{
SCOPED_TRACE("unsupported version");
DoCheck(UnsupportedLowVersionYamlString,
- "version should be >= 2 for SHT_LLVM_BB_ADDR_MAP when PGO features "
- "are enabled: version = 1 feature = 4");
+ "deprecated SHT_LLVM_BB_ADDR_MAP version: 1");
}
// Check that we fail when function entry count is enabled but not provided.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Version 2 was added more than two years ago (6015a04). So it should be safe to deprecate older versions.