aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCAsmBackend.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2025-04-05 19:01:16 -0700
committerFangrui Song <i@maskray.me>2025-04-05 19:01:16 -0700
commit38c3ad36be1facbe6db2dede7e93c0f12fb4e1dc (patch)
treebb27f587bd52481e73edb625f28ce367f4e7761e /llvm/lib/MC/MCAsmBackend.cpp
parent94821ce45fe93aa78cc5ea03cd9deac91b7af127 (diff)
downloadllvm-38c3ad36be1facbe6db2dede7e93c0f12fb4e1dc.zip
llvm-38c3ad36be1facbe6db2dede7e93c0f12fb4e1dc.tar.gz
llvm-38c3ad36be1facbe6db2dede7e93c0f12fb4e1dc.tar.bz2
Define MCAsmBackend::shouldForceRelocation
Return true if the MCValue has a specifier. When a relocation specifier is specified, GNU Assembler will generate a relocation unless the specifier can be optimized due to target-specific reasons (e.g. PPC `@l` `@ha`). This reduces targets' reliance on a MCAssembler::evaluateFixup hack `if (Target.SymSpecifier || SA.isUndefined()) {`, previosuly `if (A->getKind() != MCSymbolRefExpr::VK_None || SA.isUndefined()) {` llvm/test/MC/SystemZ/fixups.s is known to rely on this hack.
Diffstat (limited to 'llvm/lib/MC/MCAsmBackend.cpp')
-rw-r--r--llvm/lib/MC/MCAsmBackend.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCAsmBackend.cpp b/llvm/lib/MC/MCAsmBackend.cpp
index b5a0766..23cc134 100644
--- a/llvm/lib/MC/MCAsmBackend.cpp
+++ b/llvm/lib/MC/MCAsmBackend.cpp
@@ -109,6 +109,12 @@ const MCFixupKindInfo &MCAsmBackend::getFixupKindInfo(MCFixupKind Kind) const {
return Builtins[Kind];
}
+bool MCAsmBackend::shouldForceRelocation(const MCAssembler &, const MCFixup &,
+ const MCValue &Target,
+ const MCSubtargetInfo *) {
+ return Target.getSpecifier();
+}
+
bool MCAsmBackend::fixupNeedsRelaxationAdvanced(const MCAssembler &Asm,
const MCFixup &Fixup,
bool Resolved, uint64_t Value,