Skip to content

Commit cc25748

Browse files
committed
[MC] Check RelaxFixupKind instead of hard coding RISC-V/LoongArch
1 parent f1fd9d7 commit cc25748

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

llvm/include/llvm/MC/MCAsmBackend.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@ class MCAsmBackend {
5050

5151
const llvm::endianness Endian;
5252

53-
/// Fixup kind used for linker relaxation. Currently only used by RISC-V.
53+
/// Fixup kind used for linker relaxation. Currently only used by RISC-V
54+
/// and LoongArch.
5455
const unsigned RelaxFixupKind;
56+
bool allowLinkerRelaxation() const { return RelaxFixupKind != MaxFixupKind; }
5557

5658
/// Return true if this target might automatically pad instructions and thus
5759
/// need to emit padding enable/disable directives around sensative code.

llvm/lib/MC/MCExpr.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,8 +627,7 @@ static void AttemptToFoldSymbolOffsetDifference(
627627
// .size/.fill), disable the fast path.
628628
bool Layout = Asm->hasLayout();
629629
if (Layout && (InSet || !SecA.hasInstructions() ||
630-
!(Asm->getContext().getTargetTriple().isRISCV() ||
631-
Asm->getContext().getTargetTriple().isLoongArch()))) {
630+
!Asm->getBackend().allowLinkerRelaxation())) {
632631
// If both symbols are in the same fragment, return the difference of their
633632
// offsets. canGetFragmentOffset(FA) may be false.
634633
if (FA == FB && !SA.isVariable() && !SB.isVariable()) {

0 commit comments

Comments
 (0)