[PATCH] D112063: [lld][ELF] Support adrp+ldr GOT optimization for AArch64

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 11 08:45:52 PST 2022


peter.smith added a comment.

In D112063#3233346 <https://reviews.llvm.org/D112063#3233346>, @MaskRay wrote:

> (There was part of the reasons I sent D116881 <https://reviews.llvm.org/D116881> to refactor scanRelocations.)
> I just realized that handling GOT optimization in `InputSectionBase::relocateAlloc` has one downside: the GOT entry may be reserved even if no reference uses it.
> x86-64 GOTPCRELX uses `target->adjustGotPcExpr` and different `RelExpr` to suppress the GOT entry.
>
> The upside is that if we more complex transformations, we may still need some code in 
> `InputSectionBase::relocateAlloc`

One of the difficult parts of the transformation is that the transformation is only valid if the ADRP is in range of the target, and this isn't known at relocation scanning time. In practice the vast majority of programs will have the data within ADRP range so we could have a heuristic where we can definitely say everything will be in range to suppress the GOT slot. For example no linker script and total size of code/data < 4 GiB.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112063/new/

https://reviews.llvm.org/D112063



More information about the llvm-commits mailing list