mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 04:30:23 +00:00
Visibility hidden GVs do not require extra load of symbol address from the GOT or non-lazy-ptr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60519 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6a9041e5ca
commit
eb83dfde66
@ -830,7 +830,7 @@ SDValue ARMTargetLowering::LowerGlobalAddressELF(SDValue Op,
|
||||
/// GVIsIndirectSymbol - true if the GV will be accessed via an indirect symbol
|
||||
/// even in non-static mode.
|
||||
static bool GVIsIndirectSymbol(GlobalValue *GV, Reloc::Model RelocM) {
|
||||
return RelocM != Reloc::Static &&
|
||||
return RelocM != Reloc::Static && !GV->hasHiddenVisibility() &&
|
||||
(GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() ||
|
||||
(GV->isDeclaration() && !GV->hasNotBeenReadFromBitcode()));
|
||||
}
|
||||
|
@ -387,8 +387,9 @@ void PPCAsmPrinter::printOp(const MachineOperand &MO) {
|
||||
|
||||
// External or weakly linked global variables need non-lazily-resolved stubs
|
||||
if (TM.getRelocationModel() != Reloc::Static) {
|
||||
if (((GV->isDeclaration() || GV->hasWeakLinkage() ||
|
||||
GV->hasLinkOnceLinkage() || GV->hasCommonLinkage()))) {
|
||||
if (!GV->hasHiddenVisibility() &&
|
||||
(GV->isDeclaration() || GV->hasWeakLinkage() ||
|
||||
GV->hasLinkOnceLinkage() || GV->hasCommonLinkage())) {
|
||||
GVStubs.insert(Name);
|
||||
printSuffixedName(Name, "$non_lazy_ptr");
|
||||
if (GV->hasExternalWeakLinkage())
|
||||
|
@ -141,7 +141,9 @@ bool PPCSubtarget::hasLazyResolverStub(const GlobalValue *GV) const {
|
||||
// We never hae stubs if HasLazyResolverStubs=false or if in static mode.
|
||||
if (!HasLazyResolverStubs || TM.getRelocationModel() == Reloc::Static)
|
||||
return false;
|
||||
|
||||
// Extra load is not needed for symbols with hidden visibility.
|
||||
if (GV->hasHiddenVisibility())
|
||||
return false;
|
||||
return GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() ||
|
||||
GV->hasCommonLinkage() ||
|
||||
(GV->isDeclaration() && !GV->hasNotBeenReadFromBitcode());
|
||||
|
@ -391,6 +391,8 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
|
||||
FnStubs.insert(Name);
|
||||
printSuffixedName(Name, "$stub");
|
||||
}
|
||||
} else if (GV->hasHiddenVisibility()) {
|
||||
O << Name;
|
||||
} else {
|
||||
GVStubs.insert(Name);
|
||||
printSuffixedName(Name, "$non_lazy_ptr");
|
||||
|
@ -40,6 +40,9 @@ bool X86Subtarget::GVRequiresExtraLoad(const GlobalValue* GV,
|
||||
if (TM.getRelocationModel() != Reloc::Static &&
|
||||
TM.getCodeModel() != CodeModel::Large) {
|
||||
if (isTargetDarwin()) {
|
||||
if (GV->hasHiddenVisibility())
|
||||
// Extra load is not needed for symbols with hidden visibility.
|
||||
return false;
|
||||
return (!isDirectCall &&
|
||||
(GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() ||
|
||||
GV->hasCommonLinkage() ||
|
||||
|
10
test/CodeGen/X86/hidden-vis-2.ll
Normal file
10
test/CodeGen/X86/hidden-vis-2.ll
Normal file
@ -0,0 +1,10 @@
|
||||
; RUN: llvm-as < %s | llc -mtriple=i386-apple-darwin9 | grep mov | count 1
|
||||
; RUN: llvm-as < %s | llc -mtriple=x86_64-apple-darwin9 | not grep GOT
|
||||
|
||||
@x = weak hidden global i32 0 ; <i32*> [#uses=1]
|
||||
|
||||
define i32 @t() nounwind readonly {
|
||||
entry:
|
||||
%0 = load i32* @x, align 4 ; <i32> [#uses=1]
|
||||
ret i32 %0
|
||||
}
|
Loading…
Reference in New Issue
Block a user