From 7c83b7ef1796210451b839f4c58f2815f4aedfe5 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Mon, 1 Jul 2024 14:11:28 -0700 Subject: [PATCH] [MC] Remove two unused parameters from MCAsmBackend::fixupNeedsRelaxation fixupNeedsRelaxation is a simple implementation for fixupNeedsRelaxationAdvanced. Its users do not utilize MCAsmLayout or MCRelaxableFragment. Follow-up to 22c7317f1e954b34a46640db5d509bae1c633348 ("[MC] Remove the MCAsmLayout parameter from relocation related functions"). --- llvm/include/llvm/MC/MCAsmBackend.h | 5 ++--- llvm/lib/MC/MCAsmBackend.cpp | 2 +- .../Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp | 9 +++------ .../Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp | 9 +++------ llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp | 5 ++--- llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.h | 5 ++--- llvm/lib/Target/CSKY/MCTargetDesc/CSKYAsmBackend.cpp | 5 ++--- llvm/lib/Target/CSKY/MCTargetDesc/CSKYAsmBackend.h | 5 ++--- llvm/lib/Target/M68k/MCTargetDesc/M68kAsmBackend.cpp | 10 ++++------ llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp | 9 +++------ 10 files changed, 24 insertions(+), 40 deletions(-) diff --git a/llvm/include/llvm/MC/MCAsmBackend.h b/llvm/include/llvm/MC/MCAsmBackend.h index 3b4c01ea9508..3d81c39bfc77 100644 --- a/llvm/include/llvm/MC/MCAsmBackend.h +++ b/llvm/include/llvm/MC/MCAsmBackend.h @@ -165,9 +165,8 @@ public: const bool WasForced) const; /// Simple predicate for targets where !Resolved implies requiring relaxation - virtual bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value, - const MCRelaxableFragment *DF, - const MCAsmLayout &Layout) const { + virtual bool fixupNeedsRelaxation(const MCFixup &Fixup, + uint64_t Value) const { llvm_unreachable("Needed if mayNeedRelaxation may return true"); } diff --git a/llvm/lib/MC/MCAsmBackend.cpp b/llvm/lib/MC/MCAsmBackend.cpp index 9fea05c0f515..fc36f29a9033 100644 --- a/llvm/lib/MC/MCAsmBackend.cpp +++ b/llvm/lib/MC/MCAsmBackend.cpp @@ -123,7 +123,7 @@ bool MCAsmBackend::fixupNeedsRelaxationAdvanced(const MCAssembler &Asm, const bool WasForced) const { if (!Resolved) return true; - return fixupNeedsRelaxation(Fixup, Value, DF, *Asm.getLayout()); + return fixupNeedsRelaxation(Fixup, Value); } bool MCAsmBackend::isDarwinCanonicalPersonality(const MCSymbol *Sym) const { diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp index 30ef3680ae79..be470c71ae8b 100644 --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp +++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp @@ -90,9 +90,8 @@ public: uint64_t Value, bool IsResolved, const MCSubtargetInfo *STI) const override; - bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value, - const MCRelaxableFragment *DF, - const MCAsmLayout &Layout) const override; + bool fixupNeedsRelaxation(const MCFixup &Fixup, + uint64_t Value) const override; void relaxInstruction(MCInst &Inst, const MCSubtargetInfo &STI) const override; bool writeNopData(raw_ostream &OS, uint64_t Count, @@ -483,9 +482,7 @@ void AArch64AsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, } bool AArch64AsmBackend::fixupNeedsRelaxation(const MCFixup &Fixup, - uint64_t Value, - const MCRelaxableFragment *DF, - const MCAsmLayout &Layout) const { + uint64_t Value) const { // FIXME: This isn't correct for AArch64. Just moving the "generic" logic // into the targets for now. // diff --git a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp index 8eb246ef57c9..68774c12516c 100644 --- a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp +++ b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp @@ -36,9 +36,8 @@ public: const MCValue &Target, MutableArrayRef Data, uint64_t Value, bool IsResolved, const MCSubtargetInfo *STI) const override; - bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value, - const MCRelaxableFragment *DF, - const MCAsmLayout &Layout) const override; + bool fixupNeedsRelaxation(const MCFixup &Fixup, + uint64_t Value) const override; void relaxInstruction(MCInst &Inst, const MCSubtargetInfo &STI) const override; @@ -69,9 +68,7 @@ void AMDGPUAsmBackend::relaxInstruction(MCInst &Inst, } bool AMDGPUAsmBackend::fixupNeedsRelaxation(const MCFixup &Fixup, - uint64_t Value, - const MCRelaxableFragment *DF, - const MCAsmLayout &Layout) const { + uint64_t Value) const { // if the branch target has an offset of x3f this needs to be relaxed to // add a s_nop 0 immediately after branch to effectively increment offset // for hardware workaround in gfx1010 diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp index 6cd4badb7704..48b4b6902ceb 100644 --- a/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp +++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp @@ -337,9 +337,8 @@ const char *ARMAsmBackend::reasonForFixupRelaxation(const MCFixup &Fixup, return nullptr; } -bool ARMAsmBackend::fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value, - const MCRelaxableFragment *DF, - const MCAsmLayout &Layout) const { +bool ARMAsmBackend::fixupNeedsRelaxation(const MCFixup &Fixup, + uint64_t Value) const { return reasonForFixupRelaxation(Fixup, Value); } diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.h b/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.h index 328eed9b0ec4..f33cd8b7c242 100644 --- a/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.h +++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.h @@ -57,9 +57,8 @@ public: const char *reasonForFixupRelaxation(const MCFixup &Fixup, uint64_t Value) const; - bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value, - const MCRelaxableFragment *DF, - const MCAsmLayout &Layout) const override; + bool fixupNeedsRelaxation(const MCFixup &Fixup, + uint64_t Value) const override; void relaxInstruction(MCInst &Inst, const MCSubtargetInfo &STI) const override; diff --git a/llvm/lib/Target/CSKY/MCTargetDesc/CSKYAsmBackend.cpp b/llvm/lib/Target/CSKY/MCTargetDesc/CSKYAsmBackend.cpp index 1acd34c1ffe4..222dc2cf85f9 100644 --- a/llvm/lib/Target/CSKY/MCTargetDesc/CSKYAsmBackend.cpp +++ b/llvm/lib/Target/CSKY/MCTargetDesc/CSKYAsmBackend.cpp @@ -284,9 +284,8 @@ bool CSKYAsmBackend::shouldForceRelocation(const MCAssembler &Asm, return false; } -bool CSKYAsmBackend::fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value, - const MCRelaxableFragment *DF, - const MCAsmLayout &Layout) const { +bool CSKYAsmBackend::fixupNeedsRelaxation(const MCFixup &Fixup, + uint64_t Value) const { return false; } diff --git a/llvm/lib/Target/CSKY/MCTargetDesc/CSKYAsmBackend.h b/llvm/lib/Target/CSKY/MCTargetDesc/CSKYAsmBackend.h index 74e62a0e58dd..4b659f401d25 100644 --- a/llvm/lib/Target/CSKY/MCTargetDesc/CSKYAsmBackend.h +++ b/llvm/lib/Target/CSKY/MCTargetDesc/CSKYAsmBackend.h @@ -33,9 +33,8 @@ public: const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override; - bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value, - const MCRelaxableFragment *DF, - const MCAsmLayout &Layout) const override; + bool fixupNeedsRelaxation(const MCFixup &Fixup, + uint64_t Value) const override; void relaxInstruction(MCInst &Inst, const MCSubtargetInfo &STI) const override; diff --git a/llvm/lib/Target/M68k/MCTargetDesc/M68kAsmBackend.cpp b/llvm/lib/Target/M68k/MCTargetDesc/M68kAsmBackend.cpp index 1b85e6df379c..2c52fe07bb11 100644 --- a/llvm/lib/Target/M68k/MCTargetDesc/M68kAsmBackend.cpp +++ b/llvm/lib/Target/M68k/MCTargetDesc/M68kAsmBackend.cpp @@ -68,9 +68,8 @@ public: bool mayNeedRelaxation(const MCInst &Inst, const MCSubtargetInfo &STI) const override; - bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value, - const MCRelaxableFragment *DF, - const MCAsmLayout &Layout) const override; + bool fixupNeedsRelaxation(const MCFixup &Fixup, + uint64_t Value) const override; void relaxInstruction(MCInst &Inst, const MCSubtargetInfo &STI) const override; @@ -166,9 +165,8 @@ bool M68kAsmBackend::mayNeedRelaxation(const MCInst &Inst, return false; } -bool M68kAsmBackend::fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value, - const MCRelaxableFragment *DF, - const MCAsmLayout &Layout) const { +bool M68kAsmBackend::fixupNeedsRelaxation(const MCFixup &Fixup, + uint64_t Value) const { // TODO Newer CPU can use 32 bit offsets, so check for this when ready if (!isInt<16>(Value)) { llvm_unreachable("Cannot relax the instruction, value does not fit"); diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp index 790567e52b84..670ff35613db 100644 --- a/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp +++ b/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp @@ -186,9 +186,8 @@ public: bool mayNeedRelaxation(const MCInst &Inst, const MCSubtargetInfo &STI) const override; - bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value, - const MCRelaxableFragment *DF, - const MCAsmLayout &Layout) const override; + bool fixupNeedsRelaxation(const MCFixup &Fixup, + uint64_t Value) const override; void relaxInstruction(MCInst &Inst, const MCSubtargetInfo &STI) const override; @@ -743,9 +742,7 @@ bool X86AsmBackend::mayNeedRelaxation(const MCInst &MI, } bool X86AsmBackend::fixupNeedsRelaxation(const MCFixup &Fixup, - uint64_t Value, - const MCRelaxableFragment *DF, - const MCAsmLayout &Layout) const { + uint64_t Value) const { // Relax if the value is too big for a (signed) i8. return !isInt<8>(Value); }