diff options
author | Chris Lattner <sabre@nondot.org> | 2009-07-09 03:27:27 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-07-09 03:27:27 +0000 |
commit | 73b5b71369d7324dd87e89791edb7000b1d0bd29 (patch) | |
tree | cae6270303c470dcdcf3e064299b287051c5ca2d /lib/Target/X86 | |
parent | e4df756289b6d80dcfd67b9f97fd464f62fd4902 (diff) |
Reduce indentation in GVRequiresExtraLoad. Return true for windows
with DLLImport symbols even when in -static mode.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75093 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86')
-rw-r--r-- | lib/Target/X86/X86Subtarget.cpp | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/lib/Target/X86/X86Subtarget.cpp b/lib/Target/X86/X86Subtarget.cpp index 8506fa66a6..e4cd288470 100644 --- a/lib/Target/X86/X86Subtarget.cpp +++ b/lib/Target/X86/X86Subtarget.cpp @@ -40,32 +40,34 @@ AsmWriterFlavor("x86-asm-syntax", cl::init(X86Subtarget::Unset), /// or index register of the address, not the GV offset field. bool X86Subtarget::GVRequiresExtraLoad(const GlobalValue* GV, const TargetMachine& TM, - bool isDirectCall) const -{ - // FIXME: PIC - if (TM.getRelocationModel() != Reloc::Static && - TM.getCodeModel() != CodeModel::Large) { - if (isTargetDarwin()) { - if (isDirectCall) - return false; - bool isDecl = GV->isDeclaration() && !GV->hasNotBeenReadFromBitcode(); - if (GV->hasHiddenVisibility() && - (Is64Bit || (!isDecl && !GV->hasCommonLinkage()))) - // If symbol visibility is hidden, the extra load is not needed if - // target is x86-64 or the symbol is definitely defined in the current - // translation unit. - return false; - return !isDirectCall && (isDecl || GV->isWeakForLinker()); - } else if (isTargetELF()) { - // Extra load is needed for all externally visible. - if (isDirectCall) - return false; - if (GV->hasLocalLinkage() || GV->hasHiddenVisibility()) - return false; - return true; - } else if (isTargetCygMing() || isTargetWindows()) { - return (GV->hasDLLImportLinkage()); - } + bool isDirectCall) const { + // Windows targets only require an extra load for DLLImport linkage values, + // and they need these regardless of whether we're in PIC mode or not. + if (isTargetCygMing() || isTargetWindows()) + return GV->hasDLLImportLinkage(); + + if (TM.getRelocationModel() == Reloc::Static || + TM.getCodeModel() == CodeModel::Large) + return false; + + if (isTargetDarwin()) { + if (isDirectCall) + return false; + bool isDecl = GV->isDeclaration() && !GV->hasNotBeenReadFromBitcode(); + if (GV->hasHiddenVisibility() && + (Is64Bit || (!isDecl && !GV->hasCommonLinkage()))) + // If symbol visibility is hidden, the extra load is not needed if + // target is x86-64 or the symbol is definitely defined in the current + // translation unit. + return false; + return !isDirectCall && (isDecl || GV->isWeakForLinker()); + } else if (isTargetELF()) { + // Extra load is needed for all externally visible. + if (isDirectCall) + return false; + if (GV->hasLocalLinkage() || GV->hasHiddenVisibility()) + return false; + return true; } return false; } |