[llvm-commits] [llvm] r60519 - in /llvm/trunk: lib/Target/ARM/ARMISelLowering.cpp lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp lib/Target/PowerPC/PPCSubtarget.cpp lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp lib/Target/X86/X86Subtarget.cpp test/CodeGen/X86/hidden-vis-2.ll
Evan Cheng
evan.cheng at apple.com
Wed Dec 3 17:56:51 PST 2008
Author: evancheng
Date: Wed Dec 3 19:56:50 2008
New Revision: 60519
URL: http://llvm.org/viewvc/llvm-project?rev=60519&view=rev
Log:
Visibility hidden GVs do not require extra load of symbol address from the GOT or non-lazy-ptr.
Added:
llvm/trunk/test/CodeGen/X86/hidden-vis-2.ll
Modified:
llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
llvm/trunk/lib/Target/PowerPC/PPCSubtarget.cpp
llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
llvm/trunk/lib/Target/X86/X86Subtarget.cpp
Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=60519&r1=60518&r2=60519&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Wed Dec 3 19:56:50 2008
@@ -830,7 +830,7 @@
/// 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()));
}
Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=60519&r1=60518&r2=60519&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Wed Dec 3 19:56:50 2008
@@ -387,8 +387,9 @@
// 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())
Modified: llvm/trunk/lib/Target/PowerPC/PPCSubtarget.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCSubtarget.cpp?rev=60519&r1=60518&r2=60519&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCSubtarget.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCSubtarget.cpp Wed Dec 3 19:56:50 2008
@@ -141,7 +141,9 @@
// 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());
Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=60519&r1=60518&r2=60519&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Wed Dec 3 19:56:50 2008
@@ -391,6 +391,8 @@
FnStubs.insert(Name);
printSuffixedName(Name, "$stub");
}
+ } else if (GV->hasHiddenVisibility()) {
+ O << Name;
} else {
GVStubs.insert(Name);
printSuffixedName(Name, "$non_lazy_ptr");
Modified: llvm/trunk/lib/Target/X86/X86Subtarget.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.cpp?rev=60519&r1=60518&r2=60519&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86Subtarget.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86Subtarget.cpp Wed Dec 3 19:56:50 2008
@@ -40,6 +40,9 @@
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() ||
Added: llvm/trunk/test/CodeGen/X86/hidden-vis-2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/hidden-vis-2.ll?rev=60519&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/hidden-vis-2.ll (added)
+++ llvm/trunk/test/CodeGen/X86/hidden-vis-2.ll Wed Dec 3 19:56:50 2008
@@ -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
+
+ at 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
+}
More information about the llvm-commits
mailing list