Skip to content
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

AsmPrinter: Remove ELF's special lowerRelativeReference for unnamed_addr function #132684

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,6 @@ class TargetLoweringObjectFileELF : 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;

const MCExpr *lowerDSOLocalEquivalent(const DSOLocalEquivalent *Equiv,
const TargetMachine &TM) const override;

Expand Down
20 changes: 0 additions & 20 deletions llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1174,26 +1174,6 @@ MCSection *TargetLoweringObjectFileELF::getStaticDtorSection(
KeySym);
}

const MCExpr *TargetLoweringObjectFileELF::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), PLTRelativeSpecifier,
getContext()),
MCSymbolRefExpr::create(TM.getSymbol(RHS), getContext()), getContext());
}

const MCExpr *TargetLoweringObjectFileELF::lowerDSOLocalEquivalent(
const DSOLocalEquivalent *Equiv, const TargetMachine &TM) const {
assert(supportDSOLocalEquivalentLowering());
Expand Down
5 changes: 3 additions & 2 deletions llvm/test/CodeGen/X86/x86-64-plt-relative-reloc.ll
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ declare void @fn2() unnamed_addr
declare void @fn3()
@global4 = external unnamed_addr global i8

;; Generate a PC-relative relocation, which might be rejected by the linker if the referenced symbol is preemptible.
; CHECK: .long 0
; CHECK-NEXT: .long (fn1@PLT-vtable)-4
; CHECK-NEXT: .long (fn2@PLT-vtable)-4
; CHECK-NEXT: .long (fn1-vtable)-4
; CHECK-NEXT: .long (fn2-vtable)-4
; CHECK-NEXT: .long (fn3-vtable)-4
; CHECK-NEXT: .long (global4-vtable)-4
4 changes: 2 additions & 2 deletions llvm/test/CodeGen/X86/x86-plt-relative-reloc.ll
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ declare void @fn2() unnamed_addr
declare void @fn3()

; CHECK: .long 0
; CHECK-NEXT: .long (fn1@PLT-vtable)-4
; CHECK-NEXT: .long (fn2@PLT-vtable)-4
; CHECK-NEXT: .long (fn1-vtable)-4
; CHECK-NEXT: .long (fn2-vtable)-4
; CHECK-NEXT: .long (fn3-vtable)-4
Loading