summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorTim Northover <Tim.Northover@arm.com>2013-02-28 14:36:31 +0000
committerTim Northover <Tim.Northover@arm.com>2013-02-28 14:36:31 +0000
commitc3c5c0971dfeb85fc4b3862b264062230071dbcb (patch)
treedd26dda97483d547be5d21e3237db33d5fde49b3 /llvm/lib
parentb9d4fd210b87b3c350900bf940ac238324d0a85e (diff)
downloadbcm5719-llvm-c3c5c0971dfeb85fc4b3862b264062230071dbcb.tar.gz
bcm5719-llvm-c3c5c0971dfeb85fc4b3862b264062230071dbcb.zip
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. llvm-svn: 176259
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/AArch64/AArch64ISelLowering.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index fa9dcbfc21f..34cc0e3b3b8 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/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,
OpenPOWER on IntegriCloud