[llvm] [BOLT][NFC] Be more obvious about selecting X86 (PR #88527)
Nathan Sidwell via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 12 08:34:47 PDT 2024
https://github.com/urnathan created https://github.com/llvm/llvm-project/pull/88527
There are a few places where 'x86' is being implied by '!aarch64 && !riscv', that's neither obvious nor scalable. Replace with `isX86()` as appropriate.
>From e1b40978d3a911ff492c831484dea2464a663cdb Mon Sep 17 00:00:00 2001
From: Nathan Sidwell <nathan at acm.org>
Date: Fri, 12 Apr 2024 09:50:59 -0400
Subject: [PATCH] [BOLT][NFC] Be more obvious about selecting X86
---
bolt/lib/Core/BinaryContext.cpp | 2 +-
bolt/lib/Core/BinaryEmitter.cpp | 2 +-
bolt/lib/Rewrite/RewriteInstance.cpp | 6 ++++--
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/bolt/lib/Core/BinaryContext.cpp b/bolt/lib/Core/BinaryContext.cpp
index 47eae964e816c5..b97b47929cf823 100644
--- a/bolt/lib/Core/BinaryContext.cpp
+++ b/bolt/lib/Core/BinaryContext.cpp
@@ -1864,7 +1864,7 @@ MarkerSymType BinaryContext::getMarkerType(const SymbolRef &Symbol) const {
// For aarch64 and riscv, the ABI defines mapping symbols so we identify data
// in the code section (see IHI0056B). $x identifies a symbol starting code or
// the end of a data chunk inside code, $d identifies start of data.
- if ((!isAArch64() && !isRISCV()) || ELFSymbolRef(Symbol).getSize())
+ if (isX86() || ELFSymbolRef(Symbol).getSize())
return MarkerSymType::NONE;
Expected<StringRef> NameOrError = Symbol.getName();
diff --git a/bolt/lib/Core/BinaryEmitter.cpp b/bolt/lib/Core/BinaryEmitter.cpp
index 97d19b75200f51..6f86ddc774544a 100644
--- a/bolt/lib/Core/BinaryEmitter.cpp
+++ b/bolt/lib/Core/BinaryEmitter.cpp
@@ -512,7 +512,7 @@ void BinaryEmitter::emitFunctionBody(BinaryFunction &BF, FunctionFragment &FF,
// Emit sized NOPs via MCAsmBackend::writeNopData() interface on x86.
// This is a workaround for invalid NOPs handling by asm/disasm layer.
- if (BC.MIB->isNoop(Instr) && BC.isX86()) {
+ if (BC.isX86() && BC.MIB->isNoop(Instr)) {
if (std::optional<uint32_t> Size = BC.MIB->getSize(Instr)) {
SmallString<15> Code;
raw_svector_ostream VecOS(Code);
diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp
index 0c8ee0d417233b..66e86cbd7189c7 100644
--- a/bolt/lib/Rewrite/RewriteInstance.cpp
+++ b/bolt/lib/Rewrite/RewriteInstance.cpp
@@ -1670,7 +1670,9 @@ void RewriteInstance::disassemblePLT() {
return disassemblePLTSectionAArch64(Section);
if (BC->isRISCV())
return disassemblePLTSectionRISCV(Section);
- return disassemblePLTSectionX86(Section, EntrySize);
+ if (BC->isX86())
+ return disassemblePLTSectionX86(Section, EntrySize);
+ llvm_unreachable("Unmplemented PLT");
};
for (BinarySection &Section : BC->allocatableSections()) {
@@ -2600,7 +2602,7 @@ void RewriteInstance::handleRelocation(const SectionRef &RelocatedSection,
const bool IsToCode = ReferencedSection && ReferencedSection->isText();
// Special handling of PC-relative relocations.
- if (!IsAArch64 && !BC->isRISCV() && Relocation::isPCRelative(RType)) {
+ if (BC->isX86() && Relocation::isPCRelative(RType)) {
if (!IsFromCode && IsToCode) {
// PC-relative relocations from data to code are tricky since the
// original information is typically lost after linking, even with
More information about the llvm-commits
mailing list