Skip to content

Commit 603fa4c

Browse files
authored
[BOLT][NFC] Be more obvious about selecting X86 (#88527)
Use `isX86()` rather than `!isAArch64() && !isRISCV()`, and similar.
1 parent 51d85b7 commit 603fa4c

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

bolt/lib/Core/BinaryContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1880,7 +1880,7 @@ MarkerSymType BinaryContext::getMarkerType(const SymbolRef &Symbol) const {
18801880
// For aarch64 and riscv, the ABI defines mapping symbols so we identify data
18811881
// in the code section (see IHI0056B). $x identifies a symbol starting code or
18821882
// the end of a data chunk inside code, $d identifies start of data.
1883-
if ((!isAArch64() && !isRISCV()) || ELFSymbolRef(Symbol).getSize())
1883+
if (isX86() || ELFSymbolRef(Symbol).getSize())
18841884
return MarkerSymType::NONE;
18851885

18861886
Expected<StringRef> NameOrError = Symbol.getName();

bolt/lib/Core/BinaryEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ void BinaryEmitter::emitFunctionBody(BinaryFunction &BF, FunctionFragment &FF,
512512

513513
// Emit sized NOPs via MCAsmBackend::writeNopData() interface on x86.
514514
// This is a workaround for invalid NOPs handling by asm/disasm layer.
515-
if (BC.MIB->isNoop(Instr) && BC.isX86()) {
515+
if (BC.isX86() && BC.MIB->isNoop(Instr)) {
516516
if (std::optional<uint32_t> Size = BC.MIB->getSize(Instr)) {
517517
SmallString<15> Code;
518518
raw_svector_ostream VecOS(Code);

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,7 +1670,9 @@ void RewriteInstance::disassemblePLT() {
16701670
return disassemblePLTSectionAArch64(Section);
16711671
if (BC->isRISCV())
16721672
return disassemblePLTSectionRISCV(Section);
1673-
return disassemblePLTSectionX86(Section, EntrySize);
1673+
if (BC->isX86())
1674+
return disassemblePLTSectionX86(Section, EntrySize);
1675+
llvm_unreachable("Unmplemented PLT");
16741676
};
16751677

16761678
for (BinarySection &Section : BC->allocatableSections()) {
@@ -2605,7 +2607,7 @@ void RewriteInstance::handleRelocation(const SectionRef &RelocatedSection,
26052607
const bool IsToCode = ReferencedSection && ReferencedSection->isText();
26062608

26072609
// Special handling of PC-relative relocations.
2608-
if (!IsAArch64 && !BC->isRISCV() && Relocation::isPCRelative(RType)) {
2610+
if (BC->isX86() && Relocation::isPCRelative(RType)) {
26092611
if (!IsFromCode && IsToCode) {
26102612
// PC-relative relocations from data to code are tricky since the
26112613
// original information is typically lost after linking, even with

0 commit comments

Comments
 (0)