[llvm] a15f1bf - [RISCV] Avoid calling isSymbolRefDifferenceFullyResolvedImpl. NFC

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 20 19:41:16 PDT 2024


Author: Fangrui Song
Date: 2024-09-20T19:41:11-07:00
New Revision: a15f1bfa949ba9f46a04e3972e4b0698ce8f3a01

URL: https://github.com/llvm/llvm-project/commit/a15f1bfa949ba9f46a04e3972e4b0698ce8f3a01
DIFF: https://github.com/llvm/llvm-project/commit/a15f1bfa949ba9f46a04e3972e4b0698ce8f3a01.diff

LOG: [RISCV] Avoid calling isSymbolRefDifferenceFullyResolvedImpl. NFC

This member function is supposed to be private to MC. Also add an ifunc
test.

Added: 
    

Modified: 
    llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
    llvm/test/MC/RISCV/pcrel-fixups.s

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
index 237a8eaca05a04..4fe09be2ea1000 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
@@ -556,12 +556,13 @@ bool RISCVAsmBackend::evaluateTargetFixup(const MCAssembler &Asm,
     return false;
 
   const MCSymbolRefExpr *A = AUIPCTarget.getSymA();
-  const MCSymbol &SA = A->getSymbol();
+  const MCSymbolELF &SA = cast<MCSymbolELF>(A->getSymbol());
   if (A->getKind() != MCSymbolRefExpr::VK_None || SA.isUndefined())
     return false;
 
-  bool IsResolved = Asm.getWriter().isSymbolRefDifferenceFullyResolvedImpl(
-      Asm, SA, *AUIPCDF, false, true);
+  bool IsResolved = &SA.getSection() == AUIPCDF->getParent() &&
+                    SA.getBinding() == ELF::STB_LOCAL &&
+                    SA.getType() != ELF::STT_GNU_IFUNC;
   if (!IsResolved)
     return false;
 

diff  --git a/llvm/test/MC/RISCV/pcrel-fixups.s b/llvm/test/MC/RISCV/pcrel-fixups.s
index b491002263dfdd..22e317a7c96902 100644
--- a/llvm/test/MC/RISCV/pcrel-fixups.s
+++ b/llvm/test/MC/RISCV/pcrel-fixups.s
@@ -99,6 +99,15 @@ local_function:
 # RELAX: R_RISCV_RELAX	*ABS*
 # RELAX: addi	a1, a0, 0
 # RELAX: R_RISCV_PCREL_LO12_I	.Lpcrel_label5
+# RELAX: R_RISCV_RELAX	*ABS*
+
+.Lpcrel_label6:
+	auipc	a0, %pcrel_hi(ifunc)
+# NORELAX: auipc	a0, 0
+# NORELAX: R_RISCV_PCREL_HI20	ifunc
+
+# RELAX: auipc	a0, 0
+# RELAX: R_RISCV_PCREL_HI20	ifunc
 # RELAX: R_RISCV_RELAX	*ABS*
 
 	.global	global_function
@@ -110,3 +119,6 @@ global_function:
 	.type	weak_function, at function
 weak_function:
 	ret
+
+.type ifunc, %gnu_indirect_function
+.set ifunc, global_function


        


More information about the llvm-commits mailing list