[llvm] 7e6d008 - AsmPrinter: Remove unneeded lowerRelativeReference overrides

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 23 23:58:46 PDT 2025


Author: Fangrui Song
Date: 2025-03-23T23:58:41-07:00
New Revision: 7e6d008023e0892558f75ae3606d0b62000a66d0

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

LOG: AsmPrinter: Remove unneeded lowerRelativeReference overrides

The function is only called by AsmPrinter, where there is a fallback
when lowerRelativeReference returns nullptr.

wasm and XCOFF could use the fallback code.

(lowerRelativeReference was introduced in 2016 (https://reviews.llvm.org/D17938)
for C++ relative vtables, but C++ relative vtables ended up using
dso_local_equivalent. llvm/test/MC/COFF/cross-section-relative.ll also
uses this.)

Added: 
    

Modified: 
    llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
    llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h b/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
index 7392963bd341f..76571690eeda0 100644
--- a/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
+++ b/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
@@ -240,10 +240,6 @@ class TargetLoweringObjectFileWasm : public TargetLoweringObjectFile {
                                   const MCSymbol *KeySym) const override;
   MCSection *getStaticDtorSection(unsigned Priority,
                                   const MCSymbol *KeySym) const override;
-
-  const MCExpr *lowerRelativeReference(const GlobalValue *LHS,
-                                       const GlobalValue *RHS,
-                                       const TargetMachine &TM) const override;
 };
 
 class TargetLoweringObjectFileXCOFF : public TargetLoweringObjectFile {
@@ -269,10 +265,6 @@ class TargetLoweringObjectFileXCOFF : public TargetLoweringObjectFile {
   MCSection *getStaticDtorSection(unsigned Priority,
                                   const MCSymbol *KeySym) const override;
 
-  const MCExpr *lowerRelativeReference(const GlobalValue *LHS,
-                                       const GlobalValue *RHS,
-                                       const TargetMachine &TM) const override;
-
   MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind,
                                     const TargetMachine &TM) const override;
 

diff  --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index a6b5e2e94c79c..0e44acdd1dccc 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -2289,25 +2289,6 @@ bool TargetLoweringObjectFileWasm::shouldPutJumpTableInFunctionSection(
   return false;
 }
 
-const MCExpr *TargetLoweringObjectFileWasm::lowerRelativeReference(
-    const GlobalValue *LHS, const GlobalValue *RHS,
-    const TargetMachine &TM) const {
-  // We may only use a PLT-relative relocation to refer to unnamed_addr
-  // functions.
-  if (!LHS->hasGlobalUnnamedAddr() || !LHS->getValueType()->isFunctionTy())
-    return nullptr;
-
-  // Basic correctness checks.
-  if (LHS->getType()->getPointerAddressSpace() != 0 ||
-      RHS->getType()->getPointerAddressSpace() != 0 || LHS->isThreadLocal() ||
-      RHS->isThreadLocal())
-    return nullptr;
-
-  return MCBinaryExpr::createSub(
-      MCSymbolRefExpr::create(TM.getSymbol(LHS), getContext()),
-      MCSymbolRefExpr::create(TM.getSymbol(RHS), getContext()), getContext());
-}
-
 void TargetLoweringObjectFileWasm::InitializeWasm() {
   StaticCtorSection =
       getContext().getWasmSection(".init_array", SectionKind::getData());
@@ -2635,13 +2616,6 @@ MCSection *TargetLoweringObjectFileXCOFF::getStaticDtorSection(
   report_fatal_error("no static destructor section on AIX");
 }
 
-const MCExpr *TargetLoweringObjectFileXCOFF::lowerRelativeReference(
-    const GlobalValue *LHS, const GlobalValue *RHS,
-    const TargetMachine &TM) const {
-  /* Not implemented yet, but don't crash, return nullptr. */
-  return nullptr;
-}
-
 XCOFF::StorageClass
 TargetLoweringObjectFileXCOFF::getStorageClassForGlobal(const GlobalValue *GV) {
   assert(!isa<GlobalIFunc>(GV) && "GlobalIFunc is not supported on AIX.");


        


More information about the llvm-commits mailing list