summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/AArch64/AArch64Subtarget.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2016-05-26 12:42:55 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2016-05-26 12:42:55 +0000
commita224de06bc816812a5918c146b351c92b05d6ed8 (patch)
tree97896ec7bf30ba9cca506e29428292f18708b258 /llvm/lib/Target/AArch64/AArch64Subtarget.cpp
parent8437bb70fdc582b64e3fb0a02033684a2ae386bc (diff)
downloadbcm5719-llvm-a224de06bc816812a5918c146b351c92b05d6ed8.tar.gz
bcm5719-llvm-a224de06bc816812a5918c146b351c92b05d6ed8.zip
Use shouldAssumeDSOLocal on AArch64.
This reduces code duplication and now AArch64 also handles PIE. llvm-svn: 270844
Diffstat (limited to 'llvm/lib/Target/AArch64/AArch64Subtarget.cpp')
-rw-r--r--llvm/lib/Target/AArch64/AArch64Subtarget.cpp25
1 files changed, 6 insertions, 19 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64Subtarget.cpp b/llvm/lib/Target/AArch64/AArch64Subtarget.cpp
index 3cd03e8edd1..7d8aa0c9485 100644
--- a/llvm/lib/Target/AArch64/AArch64Subtarget.cpp
+++ b/llvm/lib/Target/AArch64/AArch64Subtarget.cpp
@@ -14,6 +14,7 @@
#include "AArch64Subtarget.h"
#include "AArch64InstrInfo.h"
#include "AArch64PBQPRegAlloc.h"
+#include "llvm/CodeGen/Analysis.h"
#include "llvm/CodeGen/MachineScheduler.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/Support/TargetRegistry.h"
@@ -73,39 +74,25 @@ const RegisterBankInfo *AArch64Subtarget::getRegBankInfo() const {
unsigned char
AArch64Subtarget::ClassifyGlobalReference(const GlobalValue *GV,
const TargetMachine &TM) const {
- bool isDef = GV->isStrongDefinitionForLinker();
-
// MachO large model always goes via a GOT, simply to get a single 8-byte
// absolute relocation on all global addresses.
if (TM.getCodeModel() == CodeModel::Large && isTargetMachO())
return AArch64II::MO_GOT;
+ Reloc::Model RM = TM.getRelocationModel();
+ if (!shouldAssumeDSOLocal(RM, TargetTriple, *GV->getParent(), GV))
+ return AArch64II::MO_GOT;
+
// The small code mode's direct accesses use ADRP, which cannot necessarily
// produce the value 0 (if the code is above 4GB).
if (TM.getCodeModel() == CodeModel::Small && GV->hasExternalWeakLinkage()) {
// In PIC mode use the GOT, but in absolute mode use a constant pool load.
- if (TM.getRelocationModel() == Reloc::Static)
+ if (RM == Reloc::Static)
return AArch64II::MO_CONSTPOOL;
else
return AArch64II::MO_GOT;
}
- // If symbol visibility is hidden, the extra load is not needed if
- // the symbol is definitely defined in the current translation unit.
-
- // The handling of non-hidden symbols in PIC mode is rather target-dependent:
- // + On MachO, if the symbol is defined in this module the GOT can be
- // skipped.
- // + On ELF, the R_AARCH64_COPY relocation means that even symbols actually
- // defined could end up in unexpected places. Use a GOT.
- if (TM.getRelocationModel() != Reloc::Static && GV->hasDefaultVisibility()) {
- if (isTargetMachO())
- return isDef ? AArch64II::MO_NO_FLAG : AArch64II::MO_GOT;
- else
- // No need to go through the GOT for local symbols on ELF.
- return GV->hasLocalLinkage() ? AArch64II::MO_NO_FLAG : AArch64II::MO_GOT;
- }
-
return AArch64II::MO_NO_FLAG;
}
OpenPOWER on IntegriCloud