diff options
author | Tim Northover <Tim.Northover@arm.com> | 2013-02-28 14:36:31 +0000 |
---|---|---|
committer | Tim Northover <Tim.Northover@arm.com> | 2013-02-28 14:36:31 +0000 |
commit | 6ff20f205b2aa126b268bcada9920f56715161be (patch) | |
tree | eee57d62d7c938a0dbe738a9be3297f7d0334f6e /lib/Target | |
parent | 5366ab21f4595d0e3888b2d23f38469da2465b8d (diff) | |
download | external_llvm-6ff20f205b2aa126b268bcada9920f56715161be.zip external_llvm-6ff20f205b2aa126b268bcada9920f56715161be.tar.gz external_llvm-6ff20f205b2aa126b268bcada9920f56715161be.tar.bz2 |
AArch64: be more careful resorting to inefficient addressing for weak vars.
If an otherwise weak var is actually defined in this unit, it can't be
undefined at runtime so we can use normal global variable sequences (ADRP/ADD)
to access it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176259 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target')
-rw-r--r-- | lib/Target/AArch64/AArch64ISelLowering.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/Target/AArch64/AArch64ISelLowering.cpp b/lib/Target/AArch64/AArch64ISelLowering.cpp index fa9dcbf..34cc0e3 100644 --- a/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -1852,11 +1852,10 @@ AArch64TargetLowering::LowerGlobalAddressELF(SDValue Op, const GlobalValue *GV = GN->getGlobal(); unsigned Alignment = GV->getAlignment(); Reloc::Model RelocM = getTargetMachine().getRelocationModel(); - - if (GV->isWeakForLinker() && RelocM == Reloc::Static) { - // Weak symbols can't use ADRP/ADD pair since they should evaluate to - // zero when undefined. In PIC mode the GOT can take care of this, but in - // absolute mode we use a constant pool load. + if (GV->isWeakForLinker() && GV->isDeclaration() && RelocM == Reloc::Static) { + // Weak undefined symbols can't use ADRP/ADD pair since they should evaluate + // to zero when they remain undefined. In PIC mode the GOT can take care of + // this, but in absolute mode we use a constant pool load. SDValue PoolAddr; PoolAddr = DAG.getNode(AArch64ISD::WrapperSmall, dl, PtrVT, DAG.getTargetConstantPool(GV, PtrVT, 0, 0, |