diff options
author | Craig Topper <craig.topper@sifive.com> | 2023-12-07 13:17:58 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-07 13:17:58 -0800 |
commit | e87f33d9ce785668223c3bcc4e06956985cccda1 (patch) | |
tree | 2dc55857cbb49063f69b754b262c060d95b52280 /llvm/lib/MC/MCAssembler.cpp | |
parent | ab4d6cd6d14cef1a167de1aea2fe44900d1d7309 (diff) | |
download | llvm-e87f33d9ce785668223c3bcc4e06956985cccda1.zip llvm-e87f33d9ce785668223c3bcc4e06956985cccda1.tar.gz llvm-e87f33d9ce785668223c3bcc4e06956985cccda1.tar.bz2 |
[RISCV][MC] Pass MCSubtargetInfo down to shouldForceRelocation and evaluateTargetFixup. (#73721)
Instead of using the STI stored in RISCVAsmBackend, try to get it from
the MCFragment.
This addresses the issue raised here
https://discourse.llvm.org/t/possible-problem-related-to-subtarget-usage/75283
Diffstat (limited to 'llvm/lib/MC/MCAssembler.cpp')
-rw-r--r-- | llvm/lib/MC/MCAssembler.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp index 901a66f..def1304 100644 --- a/llvm/lib/MC/MCAssembler.cpp +++ b/llvm/lib/MC/MCAssembler.cpp @@ -193,9 +193,9 @@ const MCSymbol *MCAssembler::getAtom(const MCSymbol &S) const { return S.getFragment()->getAtom(); } -bool MCAssembler::evaluateFixup(const MCAsmLayout &Layout, - const MCFixup &Fixup, const MCFragment *DF, - MCValue &Target, uint64_t &Value, +bool MCAssembler::evaluateFixup(const MCAsmLayout &Layout, const MCFixup &Fixup, + const MCFragment *DF, MCValue &Target, + const MCSubtargetInfo *STI, uint64_t &Value, bool &WasForced) const { ++stats::evaluateFixup; @@ -227,7 +227,7 @@ bool MCAssembler::evaluateFixup(const MCAsmLayout &Layout, if (IsTarget) return getBackend().evaluateTargetFixup(*this, Layout, Fixup, DF, Target, - Value, WasForced); + STI, Value, WasForced); unsigned FixupFlags = getBackendPtr()->getFixupKindInfo(Fixup.getKind()).Flags; bool IsPCRel = getBackendPtr()->getFixupKindInfo(Fixup.getKind()).Flags & @@ -282,7 +282,8 @@ bool MCAssembler::evaluateFixup(const MCAsmLayout &Layout, } // Let the backend force a relocation if needed. - if (IsResolved && getBackend().shouldForceRelocation(*this, Fixup, Target)) { + if (IsResolved && + getBackend().shouldForceRelocation(*this, Fixup, Target, STI)) { IsResolved = false; WasForced = true; } @@ -796,13 +797,13 @@ void MCAssembler::writeSectionData(raw_ostream &OS, const MCSection *Sec, std::tuple<MCValue, uint64_t, bool> MCAssembler::handleFixup(const MCAsmLayout &Layout, MCFragment &F, - const MCFixup &Fixup) { + const MCFixup &Fixup, const MCSubtargetInfo *STI) { // Evaluate the fixup. MCValue Target; uint64_t FixedValue; bool WasForced; - bool IsResolved = evaluateFixup(Layout, Fixup, &F, Target, FixedValue, - WasForced); + bool IsResolved = + evaluateFixup(Layout, Fixup, &F, Target, STI, FixedValue, WasForced); if (!IsResolved) { // The fixup was unresolved, we need a relocation. Inform the object // writer of the relocation, and give it an opportunity to adjust the @@ -936,7 +937,7 @@ void MCAssembler::layout(MCAsmLayout &Layout) { bool IsResolved; MCValue Target; std::tie(Target, FixedValue, IsResolved) = - handleFixup(Layout, Frag, Fixup); + handleFixup(Layout, Frag, Fixup, STI); getBackend().applyFixup(*this, Fixup, Target, Contents, FixedValue, IsResolved, STI); } @@ -960,7 +961,8 @@ bool MCAssembler::fixupNeedsRelaxation(const MCFixup &Fixup, MCValue Target; uint64_t Value; bool WasForced; - bool Resolved = evaluateFixup(Layout, Fixup, DF, Target, Value, WasForced); + bool Resolved = evaluateFixup(Layout, Fixup, DF, Target, + DF->getSubtargetInfo(), Value, WasForced); if (Target.getSymA() && Target.getSymA()->getKind() == MCSymbolRefExpr::VK_X86_ABS8 && Fixup.getKind() == FK_Data_1) |