Skip to content

Commit 15c9f27

Browse files
committed
MCAsmBackend: Remove the MCAssembler argument from shouldForceRelocation
It is only required by ARM, which can now use the member variable.
1 parent 871b0a3 commit 15c9f27

File tree

17 files changed

+22
-33
lines changed

17 files changed

+22
-33
lines changed

llvm/include/llvm/MC/MCAsmBackend.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ class MCAsmBackend {
9595
virtual MCFixupKindInfo getFixupKindInfo(MCFixupKind Kind) const;
9696

9797
// Hook used by the default `addReloc` to check if a relocation is needed.
98-
virtual bool shouldForceRelocation(const MCAssembler &, const MCFixup &,
99-
const MCValue &) {
98+
virtual bool shouldForceRelocation(const MCFixup &, const MCValue &) {
10099
return false;
101100
}
102101

llvm/lib/MC/MCAsmBackend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ bool MCAsmBackend::fixupNeedsRelaxationAdvanced(const MCAssembler &,
123123
bool MCAsmBackend::addReloc(MCAssembler &Asm, const MCFragment &F,
124124
const MCFixup &Fixup, const MCValue &Target,
125125
uint64_t &FixedValue, bool IsResolved) {
126-
if (IsResolved && shouldForceRelocation(Asm, Fixup, Target))
126+
if (IsResolved && shouldForceRelocation(Fixup, Target))
127127
IsResolved = false;
128128
if (!IsResolved)
129129
Asm.getWriter().recordRelocation(Asm, &F, Fixup, Target, FixedValue);

llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class AArch64AsmBackend : public MCAsmBackend {
9494

9595
unsigned getFixupKindContainereSizeInBytes(unsigned Kind) const;
9696

97-
bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup,
97+
bool shouldForceRelocation(const MCFixup &Fixup,
9898
const MCValue &Target) override;
9999
};
100100

@@ -518,8 +518,7 @@ bool AArch64AsmBackend::writeNopData(raw_ostream &OS, uint64_t Count,
518518
return true;
519519
}
520520

521-
bool AArch64AsmBackend::shouldForceRelocation(const MCAssembler &Asm,
522-
const MCFixup &Fixup,
521+
bool AArch64AsmBackend::shouldForceRelocation(const MCFixup &Fixup,
523522
const MCValue &Target) {
524523
// The ADRP instruction adds some multiple of 0x1000 to the current PC &
525524
// ~0xfff. This means that the required offset to reach a symbol can vary by

llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ class AMDGPUAsmBackend : public MCAsmBackend {
5050

5151
std::optional<MCFixupKind> getFixupKind(StringRef Name) const override;
5252
MCFixupKindInfo getFixupKindInfo(MCFixupKind Kind) const override;
53-
bool shouldForceRelocation(const MCAssembler &, const MCFixup &,
54-
const MCValue &) override;
53+
bool shouldForceRelocation(const MCFixup &, const MCValue &) override;
5554
};
5655

5756
} //End anonymous namespace
@@ -189,8 +188,7 @@ MCFixupKindInfo AMDGPUAsmBackend::getFixupKindInfo(MCFixupKind Kind) const {
189188
return Infos[Kind - FirstTargetFixupKind];
190189
}
191190

192-
bool AMDGPUAsmBackend::shouldForceRelocation(const MCAssembler &,
193-
const MCFixup &,
191+
bool AMDGPUAsmBackend::shouldForceRelocation(const MCFixup &,
194192
const MCValue &Target) {
195193
return Target.getSpecifier();
196194
}

llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -969,8 +969,7 @@ unsigned ARMAsmBackend::adjustFixupValue(const MCAssembler &Asm,
969969
}
970970
}
971971

972-
bool ARMAsmBackend::shouldForceRelocation(const MCAssembler &Asm,
973-
const MCFixup &Fixup,
972+
bool ARMAsmBackend::shouldForceRelocation(const MCFixup &Fixup,
974973
const MCValue &Target) {
975974
const MCSymbol *Sym = Target.getAddSym();
976975
const unsigned FixupKind = Fixup.getKind();
@@ -987,7 +986,7 @@ bool ARMAsmBackend::shouldForceRelocation(const MCAssembler &Asm,
987986
}
988987
// Create relocations for unconditional branches to function symbols with
989988
// different execution mode in ELF binaries.
990-
if (needsInterworking(Asm, Sym, Fixup.getTargetKind()))
989+
if (needsInterworking(*Asm, Sym, Fixup.getTargetKind()))
991990
return true;
992991
// We must always generate a relocation for BL/BLX instructions if we have
993992
// a symbol to reference, as the linker relies on knowing the destination

llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class ARMAsmBackend : public MCAsmBackend {
3030

3131
MCFixupKindInfo getFixupKindInfo(MCFixupKind Kind) const override;
3232

33-
bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup,
33+
bool shouldForceRelocation(const MCFixup &Fixup,
3434
const MCValue &Target) override;
3535

3636
unsigned adjustFixupValue(const MCAssembler &Asm, const MCFixup &Fixup,

llvm/lib/Target/CSKY/MCTargetDesc/CSKYAsmBackend.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,7 @@ bool CSKYAsmBackend::mayNeedRelaxation(const MCInst &Inst,
250250
}
251251
}
252252

253-
bool CSKYAsmBackend::shouldForceRelocation(const MCAssembler &Asm,
254-
const MCFixup &Fixup,
253+
bool CSKYAsmBackend::shouldForceRelocation(const MCFixup &Fixup,
255254
const MCValue &Target /*STI*/) {
256255
if (Target.getSpecifier())
257256
return true;

llvm/lib/Target/CSKY/MCTargetDesc/CSKYAsmBackend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class CSKYAsmBackend : public MCAsmBackend {
4444
bool writeNopData(raw_ostream &OS, uint64_t Count,
4545
const MCSubtargetInfo *STI) const override;
4646

47-
bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup,
47+
bool shouldForceRelocation(const MCFixup &Fixup,
4848
const MCValue &Target) override;
4949

5050
std::unique_ptr<MCObjectTargetWriter>

llvm/lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class HexagonAsmBackend : public MCAsmBackend {
198198
return Infos[Kind - FirstTargetFixupKind];
199199
}
200200

201-
bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup,
201+
bool shouldForceRelocation(const MCFixup &Fixup,
202202
const MCValue &Target) override {
203203
switch(Fixup.getTargetKind()) {
204204
default:

llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,7 @@ bool LoongArchAsmBackend::shouldInsertFixupForCodeAlign(MCAssembler &Asm,
242242
return true;
243243
}
244244

245-
bool LoongArchAsmBackend::shouldForceRelocation(const MCAssembler &Asm,
246-
const MCFixup &Fixup,
245+
bool LoongArchAsmBackend::shouldForceRelocation(const MCFixup &Fixup,
247246
const MCValue &Target) {
248247
switch (Fixup.getTargetKind()) {
249248
default:

0 commit comments

Comments
 (0)