[AArch 64] Use a constant pool load for weak symbol references when

using static relocation model and small code model.

Summary: currently we generate GOT based relocations for weak symbol
references regardless of the underlying relocation model. This should
be change so that in static relocation model we use a constant pool
load instead.

Patch from: Keith Walker

Reviewers: Renato Golin, Tim Northover

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217503 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Asiri Rathnayake
2014-09-10 13:54:38 +00:00
parent 96597a70dc
commit 3babc141b2
6 changed files with 73 additions and 10 deletions

View File

@@ -78,10 +78,15 @@ AArch64Subtarget::ClassifyGlobalReference(const GlobalValue *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). Therefore they must use the
// GOT.
if (TM.getCodeModel() == CodeModel::Small && GV->isWeakForLinker() && isDecl)
return AArch64II::MO_GOT;
// produce the value 0 (if the code is above 4GB).
if (TM.getCodeModel() == CodeModel::Small &&
GV->isWeakForLinker() && isDecl) {
// In PIC mode use the GOT, but in absolute mode use a constant pool load.
if (TM.getRelocationModel() == 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.