[llvm] cc25748 - [MC] Check RelaxFixupKind instead of hard coding RISC-V/LoongArch
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 5 12:20:39 PDT 2024
Author: Fangrui Song
Date: 2024-08-05T12:20:31-07:00
New Revision: cc25748d07b0adb1a0223e836e9cae22af150496
URL: https://github.com/llvm/llvm-project/commit/cc25748d07b0adb1a0223e836e9cae22af150496
DIFF: https://github.com/llvm/llvm-project/commit/cc25748d07b0adb1a0223e836e9cae22af150496.diff
LOG: [MC] Check RelaxFixupKind instead of hard coding RISC-V/LoongArch
Added:
Modified:
llvm/include/llvm/MC/MCAsmBackend.h
llvm/lib/MC/MCExpr.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/MC/MCAsmBackend.h b/llvm/include/llvm/MC/MCAsmBackend.h
index 3f88ac02cd92a..b105a294d875c 100644
--- a/llvm/include/llvm/MC/MCAsmBackend.h
+++ b/llvm/include/llvm/MC/MCAsmBackend.h
@@ -50,8 +50,10 @@ class MCAsmBackend {
const llvm::endianness Endian;
- /// Fixup kind used for linker relaxation. Currently only used by RISC-V.
+ /// Fixup kind used for linker relaxation. Currently only used by RISC-V
+ /// and LoongArch.
const unsigned RelaxFixupKind;
+ bool allowLinkerRelaxation() const { return RelaxFixupKind != MaxFixupKind; }
/// Return true if this target might automatically pad instructions and thus
/// need to emit padding enable/disable directives around sensative code.
diff --git a/llvm/lib/MC/MCExpr.cpp b/llvm/lib/MC/MCExpr.cpp
index b42a668bce23c..e4ca431c3d25f 100644
--- a/llvm/lib/MC/MCExpr.cpp
+++ b/llvm/lib/MC/MCExpr.cpp
@@ -627,8 +627,7 @@ static void AttemptToFoldSymbolOffsetDifference(
// .size/.fill), disable the fast path.
bool Layout = Asm->hasLayout();
if (Layout && (InSet || !SecA.hasInstructions() ||
- !(Asm->getContext().getTargetTriple().isRISCV() ||
- Asm->getContext().getTargetTriple().isLoongArch()))) {
+ !Asm->getBackend().allowLinkerRelaxation())) {
// If both symbols are in the same fragment, return the
diff erence of their
// offsets. canGetFragmentOffset(FA) may be false.
if (FA == FB && !SA.isVariable() && !SB.isVariable()) {
More information about the llvm-commits
mailing list