[llvm] f0ff2be - MCAsmBackend: Remove MCSubtargetInfo argument

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri May 23 20:55:48 PDT 2025


Author: Fangrui Song
Date: 2025-05-23T20:55:42-07:00
New Revision: f0ff2bea75f45a72143ac7fcd16a1199eb5ebf6e

URL: https://github.com/llvm/llvm-project/commit/f0ff2bea75f45a72143ac7fcd16a1199eb5ebf6e
DIFF: https://github.com/llvm/llvm-project/commit/f0ff2bea75f45a72143ac7fcd16a1199eb5ebf6e.diff

LOG: MCAsmBackend: Remove MCSubtargetInfo argument

After #141311 removed the MCSubtargetInfo argument from
shouldForceRelocation, addReloc does not need this argument, either.

In a rare scenario that the information is needed, the target should
check the MCFragment subclass and get it from
MCDataFragment/MCRelaxableFragment.

Added: 
    

Modified: 
    llvm/include/llvm/MC/MCAsmBackend.h
    llvm/lib/MC/MCAsmBackend.cpp
    llvm/lib/MC/MCAssembler.cpp
    llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp
    llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.h
    llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.cpp
    llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.h
    llvm/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp
    llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
    llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/MC/MCAsmBackend.h b/llvm/include/llvm/MC/MCAsmBackend.h
index ef924e167029d..ec70dc8811185 100644
--- a/llvm/include/llvm/MC/MCAsmBackend.h
+++ b/llvm/include/llvm/MC/MCAsmBackend.h
@@ -117,8 +117,7 @@ class MCAsmBackend {
 
   virtual bool addReloc(MCAssembler &Asm, const MCFragment &F,
                         const MCFixup &Fixup, const MCValue &Target,
-                        uint64_t &FixedValue, bool IsResolved,
-                        const MCSubtargetInfo *);
+                        uint64_t &FixedValue, bool IsResolved);
 
   /// Apply the \p Value for given \p Fixup into the provided data fragment, at
   /// the offset specified by the fixup and following the fixup kind as

diff  --git a/llvm/lib/MC/MCAsmBackend.cpp b/llvm/lib/MC/MCAsmBackend.cpp
index 622838f59a466..189ac883c87a9 100644
--- a/llvm/lib/MC/MCAsmBackend.cpp
+++ b/llvm/lib/MC/MCAsmBackend.cpp
@@ -120,8 +120,7 @@ bool MCAsmBackend::fixupNeedsRelaxationAdvanced(const MCAssembler &,
 
 bool MCAsmBackend::addReloc(MCAssembler &Asm, const MCFragment &F,
                             const MCFixup &Fixup, const MCValue &Target,
-                            uint64_t &FixedValue, bool IsResolved,
-                            const MCSubtargetInfo *STI) {
+                            uint64_t &FixedValue, bool IsResolved) {
   if (IsResolved && shouldForceRelocation(Asm, Fixup, Target))
     IsResolved = false;
   if (!IsResolved)

diff  --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index 96225b03893d6..f71008826888f 100644
--- a/llvm/lib/MC/MCAssembler.cpp
+++ b/llvm/lib/MC/MCAssembler.cpp
@@ -199,7 +199,7 @@ bool MCAssembler::evaluateFixup(const MCFixup &Fixup, const MCFragment *DF,
   if (IsResolved && mc::isRelocRelocation(Fixup.getKind()))
     IsResolved = false;
   IsResolved = getBackend().addReloc(const_cast<MCAssembler &>(*this), *DF,
-                                     Fixup, Target, Value, IsResolved, STI);
+                                     Fixup, Target, Value, IsResolved);
   getBackend().applyFixup(*this, Fixup, Target, Contents, Value, IsResolved,
                           STI);
   return true;

diff  --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp b/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp
index fbdff56cfb326..dfe192ab7ee80 100644
--- a/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp
+++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp
@@ -370,8 +370,7 @@ AVRAsmBackend::createObjectTargetWriter() const {
 
 bool AVRAsmBackend::addReloc(MCAssembler &Asm, const MCFragment &F,
                              const MCFixup &Fixup, const MCValue &Target,
-                             uint64_t &FixedValue, bool IsResolved,
-                             const MCSubtargetInfo *STI) {
+                             uint64_t &FixedValue, bool IsResolved) {
   // AVR sets the fixup value to bypass the assembly time overflow with a
   // relocation.
   if (IsResolved) {

diff  --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.h b/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.h
index 7752e4394fc83..d106a0d21a316 100644
--- a/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.h
+++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.h
@@ -38,8 +38,8 @@ class AVRAsmBackend : public MCAsmBackend {
   createObjectTargetWriter() const override;
 
   bool addReloc(MCAssembler &Asm, const MCFragment &F, const MCFixup &Fixup,
-                const MCValue &Target, uint64_t &FixedValue, bool IsResolved,
-                const MCSubtargetInfo *) override;
+                const MCValue &Target, uint64_t &FixedValue,
+                bool IsResolved) override;
 
   void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
                   const MCValue &Target, MutableArrayRef<char> Data,

diff  --git a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.cpp b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.cpp
index ab3ae5eedfc7d..46d104ce50dd2 100644
--- a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.cpp
+++ b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.cpp
@@ -437,11 +437,10 @@ bool LoongArchAsmBackend::writeNopData(raw_ostream &OS, uint64_t Count,
 
 bool LoongArchAsmBackend::addReloc(MCAssembler &Asm, const MCFragment &F,
                                    const MCFixup &Fixup, const MCValue &Target,
-                                   uint64_t &FixedValue, bool IsResolved,
-                                   const MCSubtargetInfo *CurSTI) {
+                                   uint64_t &FixedValue, bool IsResolved) {
   auto Fallback = [&]() {
-    return MCAsmBackend::addReloc(Asm, F, Fixup, Target, FixedValue, IsResolved,
-                                  CurSTI);
+    return MCAsmBackend::addReloc(Asm, F, Fixup, Target, FixedValue,
+                                  IsResolved);
   };
   uint64_t FixedValueA, FixedValueB;
   if (Target.getSubSym()) {

diff  --git a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.h b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.h
index 8669f735d2d64..787bcb4a04af8 100644
--- a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.h
+++ b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.h
@@ -36,8 +36,8 @@ class LoongArchAsmBackend : public MCAsmBackend {
                       const MCTargetOptions &Options);
 
   bool addReloc(MCAssembler &Asm, const MCFragment &F, const MCFixup &Fixup,
-                const MCValue &Target, uint64_t &FixedValue, bool IsResolved,
-                const MCSubtargetInfo *) override;
+                const MCValue &Target, uint64_t &FixedValue,
+                bool IsResolved) override;
 
   void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
                   const MCValue &Target, MutableArrayRef<char> Data,

diff  --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp
index 2738feabba874..7751ba4a13bd1 100644
--- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp
+++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp
@@ -135,15 +135,15 @@ class PPCAsmBackend : public MCAsmBackend {
   }
 
   bool addReloc(MCAssembler &Asm, const MCFragment &F, const MCFixup &Fixup,
-                const MCValue &TargetVal, uint64_t &FixedValue, bool IsResolved,
-                const MCSubtargetInfo *STI) override {
+                const MCValue &TargetVal, uint64_t &FixedValue,
+                bool IsResolved) override {
     // In PPC64 ELFv1, .quad .TOC. at tocbase in the .opd section is expected to
     // reference the null symbol.
     auto Target = TargetVal;
     if (Target.getSpecifier() == PPCMCExpr::VK_TOCBASE)
       Target.setAddSym(nullptr);
-    return MCAsmBackend::addReloc(Asm, F, Fixup, Target, FixedValue, IsResolved,
-                                  STI);
+    return MCAsmBackend::addReloc(Asm, F, Fixup, Target, FixedValue,
+                                  IsResolved);
   }
 
   void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,

diff  --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
index b18a488542057..1a31610a0a5e9 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
@@ -620,8 +620,7 @@ bool RISCVAsmBackend::evaluateTargetFixup(const MCAssembler &Asm,
 
 bool RISCVAsmBackend::addReloc(MCAssembler &Asm, const MCFragment &F,
                                const MCFixup &Fixup, const MCValue &Target,
-                               uint64_t &FixedValue, bool IsResolved,
-                               const MCSubtargetInfo *STI) {
+                               uint64_t &FixedValue, bool IsResolved) {
   uint64_t FixedValueA, FixedValueB;
   if (Target.getSubSym()) {
     assert(Target.getSpecifier() == 0 &&
@@ -668,8 +667,8 @@ bool RISCVAsmBackend::addReloc(MCAssembler &Asm, const MCFragment &F,
   if (IsResolved &&
       (getFixupKindInfo(Fixup.getKind()).Flags & MCFixupKindInfo::FKF_IsPCRel))
     IsResolved = isPCRelFixupResolved(Asm, Target.getAddSym(), F);
-  IsResolved = MCAsmBackend::addReloc(Asm, F, Fixup, Target, FixedValue,
-                                      IsResolved, STI);
+  IsResolved =
+      MCAsmBackend::addReloc(Asm, F, Fixup, Target, FixedValue, IsResolved);
 
   if (Fixup.isLinkerRelaxable()) {
     auto FA = MCFixup::create(Fixup.getOffset(), nullptr, ELF::R_RISCV_RELAX);

diff  --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.h b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.h
index cfb8e9a09d090..d53a70d0aa585 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.h
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.h
@@ -50,8 +50,8 @@ class RISCVAsmBackend : public MCAsmBackend {
                            uint64_t &Value) override;
 
   bool addReloc(MCAssembler &Asm, const MCFragment &F, const MCFixup &Fixup,
-                const MCValue &Target, uint64_t &FixedValue, bool IsResolved,
-                const MCSubtargetInfo *) override;
+                const MCValue &Target, uint64_t &FixedValue,
+                bool IsResolved) override;
 
   void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
                   const MCValue &Target, MutableArrayRef<char> Data,


        


More information about the llvm-commits mailing list