Thanks to visit codestin.com
Credit goes to github.com

Skip to content

LoongArch: Remove VK_CALL/VK_CALL_PLT and don't print %plt #138632

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

MaskRay
Copy link
Member

@MaskRay MaskRay commented May 6, 2025

%plt is a redundant relocation specifier: bl %plt(foo) is identical
to bl foo. Let's replace VK_CALL/VK_CALL_PLT with R_LARCH_B26 and
remove the only specifier constants.

Created using spr 1.3.5-bogner
@MaskRay MaskRay requested a review from heiher May 6, 2025 05:28
@llvmbot llvmbot added mc Machine (object) code backend:loongarch labels May 6, 2025
@MaskRay MaskRay requested a review from SixWeining May 6, 2025 05:28
@llvmbot
Copy link
Member

llvmbot commented May 6, 2025

@llvm/pr-subscribers-backend-loongarch

@llvm/pr-subscribers-mc

Author: Fangrui Song (MaskRay)

Changes

%plt is a redundant relocation specifier: bl %plt(foo) is identical
to bl foo. Let's replace VK_CALL/VK_CALL_PLT with R_LARCH_B26 and
remove the only specifier constants.


Patch is 112.02 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/138632.diff

41 Files Affected:

  • (modified) llvm/lib/Target/LoongArch/AsmParser/LoongArchAsmParser.cpp (+1-4)
  • (modified) llvm/lib/Target/LoongArch/LoongArchMCInstLower.cpp (+2-2)
  • (modified) llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCCodeEmitter.cpp (-2)
  • (modified) llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCExpr.cpp (+3-5)
  • (modified) llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCExpr.h (+1-5)
  • (modified) llvm/test/CodeGen/LoongArch/addrspacecast.ll (+1-1)
  • (modified) llvm/test/CodeGen/LoongArch/alloca.ll (+3-3)
  • (modified) llvm/test/CodeGen/LoongArch/bnez-beqz.ll (+4-4)
  • (modified) llvm/test/CodeGen/LoongArch/code-models.ll (+3-3)
  • (modified) llvm/test/CodeGen/LoongArch/double-br-fcmp.ll (+28-28)
  • (modified) llvm/test/CodeGen/LoongArch/eh-dwarf-cfa.ll (+1-1)
  • (modified) llvm/test/CodeGen/LoongArch/exception-pointer-register.ll (+3-3)
  • (modified) llvm/test/CodeGen/LoongArch/fdiv-reciprocal-estimate.ll (+19-19)
  • (modified) llvm/test/CodeGen/LoongArch/float-br-fcmp.ll (+28-28)
  • (modified) llvm/test/CodeGen/LoongArch/fp-expand.ll (+12-12)
  • (modified) llvm/test/CodeGen/LoongArch/fp-max-min.ll (+2-2)
  • (modified) llvm/test/CodeGen/LoongArch/fp-maximumnum-minimumnum.ll (+6-6)
  • (modified) llvm/test/CodeGen/LoongArch/fp-reciprocal.ll (+1-1)
  • (modified) llvm/test/CodeGen/LoongArch/fp-trunc-store.ll (+1-1)
  • (modified) llvm/test/CodeGen/LoongArch/fp16-promote.ll (+25-25)
  • (modified) llvm/test/CodeGen/LoongArch/frint.ll (+4-4)
  • (modified) llvm/test/CodeGen/LoongArch/fsqrt-reciprocal-estimate.ll (+24-24)
  • (modified) llvm/test/CodeGen/LoongArch/fsqrt.ll (+3-3)
  • (modified) llvm/test/CodeGen/LoongArch/intrinsic-csr-side-effects.ll (+1-1)
  • (modified) llvm/test/CodeGen/LoongArch/ir-instruction/atomicrmw.ll (+35-35)
  • (modified) llvm/test/CodeGen/LoongArch/ir-instruction/call.ll (+2-2)
  • (modified) llvm/test/CodeGen/LoongArch/ir-instruction/double-convert.ll (+4-4)
  • (modified) llvm/test/CodeGen/LoongArch/ir-instruction/float-convert.ll (+8-8)
  • (modified) llvm/test/CodeGen/LoongArch/ir-instruction/load-store-atomic.ll (+16-16)
  • (modified) llvm/test/CodeGen/LoongArch/ir-instruction/sdiv-udiv-srem-urem.ll (+10-10)
  • (modified) llvm/test/CodeGen/LoongArch/machinelicm-address-pseudos.ll (+2-2)
  • (modified) llvm/test/CodeGen/LoongArch/numeric-reg-names.ll (+1-1)
  • (modified) llvm/test/CodeGen/LoongArch/soft-fp-to-int.ll (+6-6)
  • (modified) llvm/test/CodeGen/LoongArch/spill-reload-cfr.ll (+1-1)
  • (modified) llvm/test/CodeGen/LoongArch/stack-realignment-with-variable-sized-objects.ll (+1-1)
  • (modified) llvm/test/CodeGen/LoongArch/stack-realignment.ll (+16-16)
  • (modified) llvm/test/CodeGen/LoongArch/statepoint-call-lowering.ll (+9-9)
  • (modified) llvm/test/CodeGen/LoongArch/tls-models.ll (+2-2)
  • (modified) llvm/test/CodeGen/LoongArch/unaligned-memcpy-inline.ll (+1-1)
  • (modified) llvm/test/CodeGen/LoongArch/vector-fp-imm.ll (+14-14)
  • (modified) llvm/test/MC/LoongArch/Relocations/relocations.s (+1-1)
diff --git a/llvm/lib/Target/LoongArch/AsmParser/LoongArchAsmParser.cpp b/llvm/lib/Target/LoongArch/AsmParser/LoongArchAsmParser.cpp
index faac1a221cb59..39c5e034f2a48 100644
--- a/llvm/lib/Target/LoongArch/AsmParser/LoongArchAsmParser.cpp
+++ b/llvm/lib/Target/LoongArch/AsmParser/LoongArchAsmParser.cpp
@@ -517,9 +517,7 @@ class LoongArchOperand : public MCParsedAsmOperand {
     int64_t Imm;
     LoongArchMCExpr::Specifier VK = LoongArchMCExpr::VK_None;
     bool IsConstantImm = evaluateConstantImm(getImm(), Imm, VK);
-    bool IsValidKind =
-        VK == LoongArchMCExpr::VK_None || VK == LoongArchMCExpr::VK_CALL ||
-        VK == LoongArchMCExpr::VK_CALL_PLT || VK == ELF::R_LARCH_B26;
+    bool IsValidKind = VK == LoongArchMCExpr::VK_None || VK == ELF::R_LARCH_B26;
     return IsConstantImm
                ? isShiftedInt<26, 2>(Imm) && IsValidKind
                : LoongArchAsmParser::classifySymbolRef(getImm(), VK) &&
@@ -793,7 +791,6 @@ ParseStatus LoongArchAsmParser::parseSImm26Operand(OperandVector &Operands) {
 
   MCSymbol *Sym = getContext().getOrCreateSymbol(Identifier);
   Res = MCSymbolRefExpr::create(Sym, getContext());
-  Res = LoongArchMCExpr::create(Res, LoongArchMCExpr::VK_CALL, getContext());
   Operands.push_back(LoongArchOperand::createImm(Res, S, E));
   return ParseStatus::Success;
 }
diff --git a/llvm/lib/Target/LoongArch/LoongArchMCInstLower.cpp b/llvm/lib/Target/LoongArch/LoongArchMCInstLower.cpp
index ae76463e7ebc8..1cd616c77b0e1 100644
--- a/llvm/lib/Target/LoongArch/LoongArchMCInstLower.cpp
+++ b/llvm/lib/Target/LoongArch/LoongArchMCInstLower.cpp
@@ -35,10 +35,10 @@ static MCOperand lowerSymbolOperand(const MachineOperand &MO, MCSymbol *Sym,
     Kind = LoongArchMCExpr::VK_None;
     break;
   case LoongArchII::MO_CALL:
-    Kind = LoongArchMCExpr::VK_CALL;
+    Kind = ELF::R_LARCH_B26;
     break;
   case LoongArchII::MO_CALL_PLT:
-    Kind = LoongArchMCExpr::VK_CALL_PLT;
+    Kind = ELF::R_LARCH_B26;
     break;
   case LoongArchII::MO_PCREL_HI:
     Kind = ELF::R_LARCH_PCALA_HI20;
diff --git a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCCodeEmitter.cpp b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCCodeEmitter.cpp
index d16fb5c52b8e8..5770a76b9f214 100644
--- a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCCodeEmitter.cpp
+++ b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCCodeEmitter.cpp
@@ -147,8 +147,6 @@ LoongArchMCCodeEmitter::getExprOpValue(const MCInst &MI, const MCOperand &MO,
       FixupKind = LoongArch::fixup_loongarch_b21;
       break;
     case ELF::R_LARCH_B26:
-    case LoongArchMCExpr::VK_CALL:
-    case LoongArchMCExpr::VK_CALL_PLT:
       FixupKind = LoongArch::fixup_loongarch_b26;
       break;
     case ELF::R_LARCH_ABS_HI20:
diff --git a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCExpr.cpp b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCExpr.cpp
index ac39b1fa411f2..583bbd4da9f18 100644
--- a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCExpr.cpp
+++ b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCExpr.cpp
@@ -32,7 +32,7 @@ const LoongArchMCExpr *LoongArchMCExpr::create(const MCExpr *Expr, uint16_t S,
 
 void LoongArchMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
   Specifier S = getSpecifier();
-  bool HasVariant = S != VK_None && S != VK_CALL;
+  bool HasVariant = S != VK_None && S != ELF::R_LARCH_B26;
 
   if (HasVariant)
     OS << '%' << getSpecifierName(specifier) << '(';
@@ -63,14 +63,12 @@ StringRef LoongArchMCExpr::getSpecifierName(uint16_t S) {
   switch (S) {
   default:
     llvm_unreachable("Invalid ELF symbol kind");
-  case VK_CALL_PLT:
+  case ELF::R_LARCH_B26:
     return "plt";
   case ELF::R_LARCH_B16:
     return "b16";
   case ELF::R_LARCH_B21:
     return "b21";
-  case ELF::R_LARCH_B26:
-    return "b26";
   case ELF::R_LARCH_ABS_HI20:
     return "abs_hi20";
   case ELF::R_LARCH_ABS_LO12:
@@ -176,7 +174,7 @@ StringRef LoongArchMCExpr::getSpecifierName(uint16_t S) {
 
 LoongArchMCExpr::Specifier LoongArchMCExpr::parseSpecifier(StringRef name) {
   return StringSwitch<LoongArchMCExpr::Specifier>(name)
-      .Case("plt", VK_CALL_PLT)
+      .Case("plt", ELF::R_LARCH_B26)
       .Case("b16", ELF::R_LARCH_B16)
       .Case("b21", ELF::R_LARCH_B21)
       .Case("b26", ELF::R_LARCH_B26)
diff --git a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCExpr.h b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCExpr.h
index aac49979fb60a..06ebbc034042b 100644
--- a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCExpr.h
+++ b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCExpr.h
@@ -23,11 +23,7 @@ class StringRef;
 class LoongArchMCExpr : public MCTargetExpr {
 public:
   using Specifier = uint16_t;
-  enum {
-    VK_None,
-    VK_CALL = 1000, // larger than relocation types
-    VK_CALL_PLT,
-  };
+  enum { VK_None };
 
 private:
   const MCExpr *Expr;
diff --git a/llvm/test/CodeGen/LoongArch/addrspacecast.ll b/llvm/test/CodeGen/LoongArch/addrspacecast.ll
index b177e8fc17dd6..d41c90b386de7 100644
--- a/llvm/test/CodeGen/LoongArch/addrspacecast.ll
+++ b/llvm/test/CodeGen/LoongArch/addrspacecast.ll
@@ -24,7 +24,7 @@ define void @cast1(ptr %ptr) {
 ; LA32-NEXT:    .cfi_def_cfa_offset 16
 ; LA32-NEXT:    st.w $ra, $sp, 12 # 4-byte Folded Spill
 ; LA32-NEXT:    .cfi_offset 1, -4
-; LA32-NEXT:    bl %plt(foo)
+; LA32-NEXT:    bl foo
 ; LA32-NEXT:    ld.w $ra, $sp, 12 # 4-byte Folded Reload
 ; LA32-NEXT:    addi.w $sp, $sp, 16
 ; LA32-NEXT:    ret
diff --git a/llvm/test/CodeGen/LoongArch/alloca.ll b/llvm/test/CodeGen/LoongArch/alloca.ll
index effd7daffe610..8a3b2aefaee6a 100644
--- a/llvm/test/CodeGen/LoongArch/alloca.ll
+++ b/llvm/test/CodeGen/LoongArch/alloca.ll
@@ -20,7 +20,7 @@ define void @simple_alloca(i32 %n) nounwind {
 ; LA32-NEXT:    bstrins.w $a0, $zero, 3, 0
 ; LA32-NEXT:    sub.w $a0, $sp, $a0
 ; LA32-NEXT:    move $sp, $a0
-; LA32-NEXT:    bl %plt(notdead)
+; LA32-NEXT:    bl notdead
 ; LA32-NEXT:    addi.w $sp, $fp, -16
 ; LA32-NEXT:    ld.w $fp, $sp, 8 # 4-byte Folded Reload
 ; LA32-NEXT:    ld.w $ra, $sp, 12 # 4-byte Folded Reload
@@ -67,7 +67,7 @@ define void @scoped_alloca(i32 %n) nounwind {
 ; LA32-NEXT:    bstrins.w $a0, $zero, 3, 0
 ; LA32-NEXT:    sub.w $a0, $sp, $a0
 ; LA32-NEXT:    move $sp, $a0
-; LA32-NEXT:    bl %plt(notdead)
+; LA32-NEXT:    bl notdead
 ; LA32-NEXT:    move $sp, $s0
 ; LA32-NEXT:    addi.w $sp, $fp, -16
 ; LA32-NEXT:    ld.w $s0, $sp, 4 # 4-byte Folded Reload
@@ -137,7 +137,7 @@ define void @alloca_callframe(i32 %n) nounwind {
 ; LA32-NEXT:    ori $a6, $zero, 7
 ; LA32-NEXT:    ori $a7, $zero, 8
 ; LA32-NEXT:    st.w $t0, $sp, 0
-; LA32-NEXT:    bl %plt(func)
+; LA32-NEXT:    bl func
 ; LA32-NEXT:    addi.w $sp, $sp, 16
 ; LA32-NEXT:    addi.w $sp, $fp, -16
 ; LA32-NEXT:    ld.w $fp, $sp, 8 # 4-byte Folded Reload
diff --git a/llvm/test/CodeGen/LoongArch/bnez-beqz.ll b/llvm/test/CodeGen/LoongArch/bnez-beqz.ll
index 93bbcbbf2bf66..3b1dabaf6ea14 100644
--- a/llvm/test/CodeGen/LoongArch/bnez-beqz.ll
+++ b/llvm/test/CodeGen/LoongArch/bnez-beqz.ll
@@ -11,7 +11,7 @@ define void @bnez_i32(i32 signext %0) nounwind {
 ; LA32-NEXT:  # %bb.1: # %f
 ; LA32-NEXT:    ret
 ; LA32-NEXT:  .LBB0_2: # %t
-; LA32-NEXT:    b %plt(bar)
+; LA32-NEXT:    b bar
 ;
 ; LA64-LABEL: bnez_i32:
 ; LA64:       # %bb.0: # %start
@@ -38,7 +38,7 @@ define void @beqz_i32(i32 signext %0) nounwind {
 ; LA32:       # %bb.0: # %start
 ; LA32-NEXT:    beqz $a0, .LBB1_2
 ; LA32-NEXT:  # %bb.1: # %t
-; LA32-NEXT:    b %plt(bar)
+; LA32-NEXT:    b bar
 ; LA32-NEXT:  .LBB1_2: # %f
 ; LA32-NEXT:    ret
 ;
@@ -70,7 +70,7 @@ define void @bnez_i64(i64 %0) nounwind {
 ; LA32-NEXT:  # %bb.1: # %f
 ; LA32-NEXT:    ret
 ; LA32-NEXT:  .LBB2_2: # %t
-; LA32-NEXT:    b %plt(bar)
+; LA32-NEXT:    b bar
 ;
 ; LA64-LABEL: bnez_i64:
 ; LA64:       # %bb.0: # %start
@@ -98,7 +98,7 @@ define void @beqz_i64(i64 %0) nounwind {
 ; LA32-NEXT:    or $a0, $a0, $a1
 ; LA32-NEXT:    beqz $a0, .LBB3_2
 ; LA32-NEXT:  # %bb.1: # %t
-; LA32-NEXT:    b %plt(bar)
+; LA32-NEXT:    b bar
 ; LA32-NEXT:  .LBB3_2: # %f
 ; LA32-NEXT:    ret
 ;
diff --git a/llvm/test/CodeGen/LoongArch/code-models.ll b/llvm/test/CodeGen/LoongArch/code-models.ll
index c012068862334..f4459655e6138 100644
--- a/llvm/test/CodeGen/LoongArch/code-models.ll
+++ b/llvm/test/CodeGen/LoongArch/code-models.ll
@@ -14,7 +14,7 @@ define i32 @call_globaladdress(i32 %a) nounwind {
 ; SMALL:       # %bb.0:
 ; SMALL-NEXT:    addi.d $sp, $sp, -16
 ; SMALL-NEXT:    st.d $ra, $sp, 8 # 8-byte Folded Spill
-; SMALL-NEXT:    bl %plt(callee)
+; SMALL-NEXT:    bl callee
 ; SMALL-NEXT:    ld.d $ra, $sp, 8 # 8-byte Folded Reload
 ; SMALL-NEXT:    addi.d $sp, $sp, 16
 ; SMALL-NEXT:    ret
@@ -55,7 +55,7 @@ define void @call_external_sym(ptr %dst) {
 ; SMALL-NEXT:    .cfi_offset 1, -8
 ; SMALL-NEXT:    ori $a2, $zero, 1000
 ; SMALL-NEXT:    move $a1, $zero
-; SMALL-NEXT:    bl %plt(memset)
+; SMALL-NEXT:    bl memset
 ; SMALL-NEXT:    ld.d $ra, $sp, 8 # 8-byte Folded Reload
 ; SMALL-NEXT:    addi.d $sp, $sp, 16
 ; SMALL-NEXT:    ret
@@ -101,7 +101,7 @@ declare i32 @callee_tail(i32 %i)
 define i32 @caller_tail(i32 %i) nounwind {
 ; SMALL-LABEL: caller_tail:
 ; SMALL:       # %bb.0: # %entry
-; SMALL-NEXT:    b %plt(callee_tail)
+; SMALL-NEXT:    b callee_tail
 ;
 ; MEDIUM-LABEL: caller_tail:
 ; MEDIUM:       # %bb.0: # %entry
diff --git a/llvm/test/CodeGen/LoongArch/double-br-fcmp.ll b/llvm/test/CodeGen/LoongArch/double-br-fcmp.ll
index 6a5b856a42b2e..cb89bcd097495 100644
--- a/llvm/test/CodeGen/LoongArch/double-br-fcmp.ll
+++ b/llvm/test/CodeGen/LoongArch/double-br-fcmp.ll
@@ -14,7 +14,7 @@ define void @br_fcmp_oeq_bcnez(double %a, double %b) nounwind {
 ; LA32-NEXT:  .LBB0_2: # %if.then
 ; LA32-NEXT:    addi.w $sp, $sp, -16
 ; LA32-NEXT:    st.w $ra, $sp, 12 # 4-byte Folded Spill
-; LA32-NEXT:    bl %plt(abort)
+; LA32-NEXT:    bl abort
 ;
 ; LA64-LABEL: br_fcmp_oeq_bcnez:
 ; LA64:       # %bb.0:
@@ -46,7 +46,7 @@ define void @br_fcmp_oeq_bceqz(double %a, double %b) nounwind {
 ; LA32-NEXT:  .LBB1_2: # %if.then
 ; LA32-NEXT:    addi.w $sp, $sp, -16
 ; LA32-NEXT:    st.w $ra, $sp, 12 # 4-byte Folded Spill
-; LA32-NEXT:    bl %plt(abort)
+; LA32-NEXT:    bl abort
 ;
 ; LA64-LABEL: br_fcmp_oeq_bceqz:
 ; LA64:       # %bb.0:
@@ -78,7 +78,7 @@ define void @br_fcmp_ogt_bcnez(double %a, double %b) nounwind {
 ; LA32-NEXT:  .LBB2_2: # %if.then
 ; LA32-NEXT:    addi.w $sp, $sp, -16
 ; LA32-NEXT:    st.w $ra, $sp, 12 # 4-byte Folded Spill
-; LA32-NEXT:    bl %plt(abort)
+; LA32-NEXT:    bl abort
 ;
 ; LA64-LABEL: br_fcmp_ogt_bcnez:
 ; LA64:       # %bb.0:
@@ -110,7 +110,7 @@ define void @br_fcmp_ogt_bceqz(double %a, double %b) nounwind {
 ; LA32-NEXT:  .LBB3_2: # %if.then
 ; LA32-NEXT:    addi.w $sp, $sp, -16
 ; LA32-NEXT:    st.w $ra, $sp, 12 # 4-byte Folded Spill
-; LA32-NEXT:    bl %plt(abort)
+; LA32-NEXT:    bl abort
 ;
 ; LA64-LABEL: br_fcmp_ogt_bceqz:
 ; LA64:       # %bb.0:
@@ -142,7 +142,7 @@ define void @br_fcmp_oge_bcnez(double %a, double %b) nounwind {
 ; LA32-NEXT:  .LBB4_2: # %if.then
 ; LA32-NEXT:    addi.w $sp, $sp, -16
 ; LA32-NEXT:    st.w $ra, $sp, 12 # 4-byte Folded Spill
-; LA32-NEXT:    bl %plt(abort)
+; LA32-NEXT:    bl abort
 ;
 ; LA64-LABEL: br_fcmp_oge_bcnez:
 ; LA64:       # %bb.0:
@@ -174,7 +174,7 @@ define void @br_fcmp_oge_bceqz(double %a, double %b) nounwind {
 ; LA32-NEXT:  .LBB5_2: # %if.then
 ; LA32-NEXT:    addi.w $sp, $sp, -16
 ; LA32-NEXT:    st.w $ra, $sp, 12 # 4-byte Folded Spill
-; LA32-NEXT:    bl %plt(abort)
+; LA32-NEXT:    bl abort
 ;
 ; LA64-LABEL: br_fcmp_oge_bceqz:
 ; LA64:       # %bb.0:
@@ -206,7 +206,7 @@ define void @br_fcmp_olt_bcnez(double %a, double %b) nounwind {
 ; LA32-NEXT:  .LBB6_2: # %if.then
 ; LA32-NEXT:    addi.w $sp, $sp, -16
 ; LA32-NEXT:    st.w $ra, $sp, 12 # 4-byte Folded Spill
-; LA32-NEXT:    bl %plt(abort)
+; LA32-NEXT:    bl abort
 ;
 ; LA64-LABEL: br_fcmp_olt_bcnez:
 ; LA64:       # %bb.0:
@@ -238,7 +238,7 @@ define void @br_fcmp_olt_bceqz(double %a, double %b) nounwind {
 ; LA32-NEXT:  .LBB7_2: # %if.then
 ; LA32-NEXT:    addi.w $sp, $sp, -16
 ; LA32-NEXT:    st.w $ra, $sp, 12 # 4-byte Folded Spill
-; LA32-NEXT:    bl %plt(abort)
+; LA32-NEXT:    bl abort
 ;
 ; LA64-LABEL: br_fcmp_olt_bceqz:
 ; LA64:       # %bb.0:
@@ -270,7 +270,7 @@ define void @br_fcmp_ole_bcnez(double %a, double %b) nounwind {
 ; LA32-NEXT:  .LBB8_2: # %if.then
 ; LA32-NEXT:    addi.w $sp, $sp, -16
 ; LA32-NEXT:    st.w $ra, $sp, 12 # 4-byte Folded Spill
-; LA32-NEXT:    bl %plt(abort)
+; LA32-NEXT:    bl abort
 ;
 ; LA64-LABEL: br_fcmp_ole_bcnez:
 ; LA64:       # %bb.0:
@@ -302,7 +302,7 @@ define void @br_fcmp_ole_bceqz(double %a, double %b) nounwind {
 ; LA32-NEXT:  .LBB9_2: # %if.then
 ; LA32-NEXT:    addi.w $sp, $sp, -16
 ; LA32-NEXT:    st.w $ra, $sp, 12 # 4-byte Folded Spill
-; LA32-NEXT:    bl %plt(abort)
+; LA32-NEXT:    bl abort
 ;
 ; LA64-LABEL: br_fcmp_ole_bceqz:
 ; LA64:       # %bb.0:
@@ -334,7 +334,7 @@ define void @br_fcmp_one_bcnez(double %a, double %b) nounwind {
 ; LA32-NEXT:  .LBB10_2: # %if.then
 ; LA32-NEXT:    addi.w $sp, $sp, -16
 ; LA32-NEXT:    st.w $ra, $sp, 12 # 4-byte Folded Spill
-; LA32-NEXT:    bl %plt(abort)
+; LA32-NEXT:    bl abort
 ;
 ; LA64-LABEL: br_fcmp_one_bcnez:
 ; LA64:       # %bb.0:
@@ -366,7 +366,7 @@ define void @br_fcmp_one_bceqz(double %a, double %b) nounwind {
 ; LA32-NEXT:  .LBB11_2: # %if.then
 ; LA32-NEXT:    addi.w $sp, $sp, -16
 ; LA32-NEXT:    st.w $ra, $sp, 12 # 4-byte Folded Spill
-; LA32-NEXT:    bl %plt(abort)
+; LA32-NEXT:    bl abort
 ;
 ; LA64-LABEL: br_fcmp_one_bceqz:
 ; LA64:       # %bb.0:
@@ -398,7 +398,7 @@ define void @br_fcmp_ord_bcnez(double %a, double %b) nounwind {
 ; LA32-NEXT:  .LBB12_2: # %if.then
 ; LA32-NEXT:    addi.w $sp, $sp, -16
 ; LA32-NEXT:    st.w $ra, $sp, 12 # 4-byte Folded Spill
-; LA32-NEXT:    bl %plt(abort)
+; LA32-NEXT:    bl abort
 ;
 ; LA64-LABEL: br_fcmp_ord_bcnez:
 ; LA64:       # %bb.0:
@@ -430,7 +430,7 @@ define void @br_fcmp_ord_bceqz(double %a, double %b) nounwind {
 ; LA32-NEXT:  .LBB13_2: # %if.then
 ; LA32-NEXT:    addi.w $sp, $sp, -16
 ; LA32-NEXT:    st.w $ra, $sp, 12 # 4-byte Folded Spill
-; LA32-NEXT:    bl %plt(abort)
+; LA32-NEXT:    bl abort
 ;
 ; LA64-LABEL: br_fcmp_ord_bceqz:
 ; LA64:       # %bb.0:
@@ -462,7 +462,7 @@ define void @br_fcmp_ueq_bcnez(double %a, double %b) nounwind {
 ; LA32-NEXT:  .LBB14_2: # %if.then
 ; LA32-NEXT:    addi.w $sp, $sp, -16
 ; LA32-NEXT:    st.w $ra, $sp, 12 # 4-byte Folded Spill
-; LA32-NEXT:    bl %plt(abort)
+; LA32-NEXT:    bl abort
 ;
 ; LA64-LABEL: br_fcmp_ueq_bcnez:
 ; LA64:       # %bb.0:
@@ -494,7 +494,7 @@ define void @br_fcmp_ueq_bceqz(double %a, double %b) nounwind {
 ; LA32-NEXT:  .LBB15_2: # %if.then
 ; LA32-NEXT:    addi.w $sp, $sp, -16
 ; LA32-NEXT:    st.w $ra, $sp, 12 # 4-byte Folded Spill
-; LA32-NEXT:    bl %plt(abort)
+; LA32-NEXT:    bl abort
 ;
 ; LA64-LABEL: br_fcmp_ueq_bceqz:
 ; LA64:       # %bb.0:
@@ -526,7 +526,7 @@ define void @br_fcmp_ugt_bcnez(double %a, double %b) nounwind {
 ; LA32-NEXT:  .LBB16_2: # %if.then
 ; LA32-NEXT:    addi.w $sp, $sp, -16
 ; LA32-NEXT:    st.w $ra, $sp, 12 # 4-byte Folded Spill
-; LA32-NEXT:    bl %plt(abort)
+; LA32-NEXT:    bl abort
 ;
 ; LA64-LABEL: br_fcmp_ugt_bcnez:
 ; LA64:       # %bb.0:
@@ -558,7 +558,7 @@ define void @br_fcmp_ugt_bceqz(double %a, double %b) nounwind {
 ; LA32-NEXT:  .LBB17_2: # %if.then
 ; LA32-NEXT:    addi.w $sp, $sp, -16
 ; LA32-NEXT:    st.w $ra, $sp, 12 # 4-byte Folded Spill
-; LA32-NEXT:    bl %plt(abort)
+; LA32-NEXT:    bl abort
 ;
 ; LA64-LABEL: br_fcmp_ugt_bceqz:
 ; LA64:       # %bb.0:
@@ -590,7 +590,7 @@ define void @br_fcmp_uge_bcnez(double %a, double %b) nounwind {
 ; LA32-NEXT:  .LBB18_2: # %if.then
 ; LA32-NEXT:    addi.w $sp, $sp, -16
 ; LA32-NEXT:    st.w $ra, $sp, 12 # 4-byte Folded Spill
-; LA32-NEXT:    bl %plt(abort)
+; LA32-NEXT:    bl abort
 ;
 ; LA64-LABEL: br_fcmp_uge_bcnez:
 ; LA64:       # %bb.0:
@@ -622,7 +622,7 @@ define void @br_fcmp_uge_bceqz(double %a, double %b) nounwind {
 ; LA32-NEXT:  .LBB19_2: # %if.then
 ; LA32-NEXT:    addi.w $sp, $sp, -16
 ; LA32-NEXT:    st.w $ra, $sp, 12 # 4-byte Folded Spill
-; LA32-NEXT:    bl %plt(abort)
+; LA32-NEXT:    bl abort
 ;
 ; LA64-LABEL: br_fcmp_uge_bceqz:
 ; LA64:       # %bb.0:
@@ -654,7 +654,7 @@ define void @br_fcmp_ult_bcnez(double %a, double %b) nounwind {
 ; LA32-NEXT:  .LBB20_2: # %if.then
 ; LA32-NEXT:    addi.w $sp, $sp, -16
 ; LA32-NEXT:    st.w $ra, $sp, 12 # 4-byte Folded Spill
-; LA32-NEXT:    bl %plt(abort)
+; LA32-NEXT:    bl abort
 ;
 ; LA64-LABEL: br_fcmp_ult_bcnez:
 ; LA64:       # %bb.0:
@@ -686,7 +686,7 @@ define void @br_fcmp_ult_bceqz(double %a, double %b) nounwind {
 ; LA32-NEXT:  .LBB21_2: # %if.then
 ; LA32-NEXT:    addi.w $sp, $sp, -16
 ; LA32-NEXT:    st.w $ra, $sp, 12 # 4-byte Folded Spill
-; LA32-NEXT:    bl %plt(abort)
+; LA32-NEXT:    bl abort
 ;
 ; LA64-LABEL: br_fcmp_ult_bceqz:
 ; LA64:       # %bb.0:
@@ -718,7 +718,7 @@ define void @br_fcmp_ule_bcnez(double %a, double %b) nounwind {
 ; LA32-NEXT:  .LBB22_2: # %if.then
 ; LA32-NEXT:    addi.w $sp, $sp, -16
 ; LA32-NEXT:    st.w $ra, $sp, 12 # 4-byte Folded Spill
-; LA32-NEXT:    bl %plt(abort)
+; LA32-NEXT:    bl abort
 ;
 ; LA64-LABEL: br_fcmp_ule_bcnez:
 ; LA64:       # %bb.0:
@@ -750,7 +750,7 @@ define void @br_fcmp_ule_bceqz(double %a, double %b) nounwind {
 ; LA32-NEXT:  .LBB23_2: # %if.then
 ; LA32-NEXT:    addi.w $sp, $sp, -16
 ; LA32-NEXT:    st.w $ra, $sp, 12 # 4-byte Folded Spill
-; LA32-NEXT:    bl %plt(abort)
+; LA32-NEXT:    bl abort
 ;
 ; LA64-LABEL: br_fcmp_ule_bceqz:
 ; LA64:       # %bb.0:
@@ -782,7 +782,7 @@ define void @br_fcmp_une_bcnez(double %a, double %b) nounwind {
 ; LA32-NEXT:  .LBB24_2: # %if.then
 ; LA32-NEXT:    addi.w $sp, $sp, -16
 ; LA32-NEXT:    st.w $ra, $sp, 12 # 4-byte Folded Spill
-; LA32-NEXT:    bl %plt(abort)
+; LA32-NEXT:    bl abort
 ;
 ; LA64-LABEL: br_fcmp_une_bcnez:
 ; LA64:       # %bb.0:
@@ -814,7 +814,7 @@ define void @br_fcmp_une_bceqz(double %a, double %b) nounwind {
 ; LA32-NEXT:  .LBB25_2: # %if.then
 ; LA32-NEXT:    addi.w $sp, $sp, -16
 ; LA32-NEXT:    st.w $ra, $sp, 12 # 4-byte Folded Spill
-; LA32-NEXT:    bl %plt(abort)
+; LA32-NEXT:    bl abort
 ;
 ; LA64-LABEL: br_fcmp_une_bceqz:
 ; LA64:       # %bb.0:
@@ -846,7 +846,7 @@ define void @br_fcmp_uno_bcnez(double %a, double %b) nounwind {
 ; LA32-NEXT:  .LBB26_2: # %if.then
 ; LA32-NEXT:    addi.w $sp, $sp, -16
 ; LA32-NEXT:    st.w $ra, $sp, 12 # 4-byte Folded Spill
-; LA32-NEXT:    bl %plt(abort)
+; LA32-NEXT:    bl abort
 ;
 ; LA64-LABEL: br_fcmp_uno_bcnez:
 ; LA64:       # %bb.0:
@@ -878,7 +878,7 @@ define void @br_fcmp_uno_bceqz(double %a, double %b) nounwind {
 ; LA32-NEXT:  .LBB27_2: # %if.then
 ; LA32-NEXT:    addi.w $sp, $sp, -16
 ; LA32-NEXT:    st.w $ra, $sp, 12 # 4-byte Folded Spill
-; LA32-NEXT:    bl %plt(abort)
+; LA32-NEXT:    bl abort
 ;
 ; LA64-LABEL: br_fcmp_uno_bceqz:
 ; LA64:       # %bb.0:
diff --git a/llvm/test/CodeGen/LoongArch/eh-dwarf-cfa.ll b/llvm/test/CodeGen/LoongArch/eh-dwarf-cfa.ll
index f23c5364b93e0..224755eb73d38 100644
--- a/llvm/test/CodeGen/LoongArch/eh-dwarf-cfa.ll
+++ b/llvm/test/CodeGen/LoongArch/eh-dwarf-cfa.ll
@@ -10,7 +10,7 @@ define void @dwarf() {
 ; LA32-NEXT:    st.w $ra, $sp, 12 # 4-byte Folded Spill
 ; LA32-NEXT:    .cfi_offset 1, -4
 ; LA32-NEXT:    addi.w $a0, $sp, 16
-; LA32-NEXT:    bl %plt(foo)
+; LA32-NEXT:    bl foo
 ; LA32-NEXT:    ld.w $ra, $sp, 12 # 4-byte Folded Reload
 ; LA32-NEXT:    addi.w $sp, $sp, 16
 ; LA32-NEXT:    ret
diff --git a/llvm/test/CodeGen/LoongArch/exception-pointer-register.ll b/llvm/test/CodeGen/LoongArch/exception-pointer-register.ll
index 91fa34aa3acfb..11cd573641071 100644
--- a/llvm/test/CodeGen/LoongArch/exception-pointer-register.ll
+++ b/llvm/test/CodeGen/LoongArch/exception-pointer-register.ll
@@ -28,13 +28,13 @@ define void @caller(ptr %p) personality ptr @__gxx_personality_v0 {
 ; LA32-NEXT:  # %bb.1: # %bb2
 ; LA32-NEXT:  .Ltmp0:
 ; LA32-NEXT:    move $a0, $fp
-; LA32-NEXT:    bl %plt(bar)
+; LA32-NEXT:    bl bar
 ; LA32-NEXT:  .Ltmp1:
 ; LA32-NEXT:    b .LBB0_3
 ; LA32-NEXT:  .LBB0_2: # %bb1
 ; LA32-NEXT:  .Ltmp2:
 ; LA32-NEXT:    move $a0, $fp
-; LA32-NEXT:    bl %plt(foo)
+; LA32-NEXT:    bl foo
 ; LA32-NEXT:  .Ltmp3:
 ; LA32-NEXT:  .LBB0_3: # %end2
 ; LA32-NEXT:    ld.w $s0, $sp, 4 # 4-byte Folded Reload
@@ -48,7 +48,7 @@ define void @caller(ptr %p) personality ptr @__gxx_personality_v0 {
 ; LA32-NEXT:    move $a0, $fp
 ; LA32-NEXT:    bl ca...
[truncated]

Comment on lines 66 to 67
case ELF::R_LARCH_B26:
return "plt";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems this case is useless if we don't print %plt any more.

Comment on lines 38 to 41
Kind = ELF::R_LARCH_B26;
break;
case LoongArchII::MO_CALL_PLT:
Kind = LoongArchMCExpr::VK_CALL_PLT;
Kind = ELF::R_LARCH_B26;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems these 2 cases can be merged into one.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. The two MO_ can probably be merged, but that should be a future change.

Created using spr 1.3.5-bogner
Copy link
Contributor

@SixWeining SixWeining left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks.

@MaskRay MaskRay merged commit 8286378 into main May 7, 2025
7 of 10 checks passed
@MaskRay MaskRay deleted the users/MaskRay/spr/loongarch-remove-vk_callvk_call_plt-and-dont-print-plt branch May 7, 2025 06:30
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request May 7, 2025
`%plt` is a redundant relocation specifier: `bl %plt(foo)` is identical
to `bl foo`. Let's replace VK_CALL/VK_CALL_PLT with R_LARCH_B26 and
remove the only specifier constants.

Pull Request: llvm/llvm-project#138632
GeorgeARM pushed a commit to GeorgeARM/llvm-project that referenced this pull request May 7, 2025
`%plt` is a redundant relocation specifier: `bl %plt(foo)` is identical
to `bl foo`. Let's replace VK_CALL/VK_CALL_PLT with R_LARCH_B26 and
remove the only specifier constants.

Pull Request: llvm#138632
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:loongarch mc Machine (object) code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants