[PATCH] D54720: [PPC64] toc-indirect to toc-relative relaxation.
Sean Fertile via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 19 12:54:18 PST 2018
sfertile created this revision.
sfertile added reviewers: syzaara, ruiu, MaskRay, rdhindsa.
Herald added subscribers: jsji, kbarton, arichardson, nemanjai, emaste.
Herald added a reviewer: espindola.
When accessing a global variable which is not defined in the translation-unit being compiled the compilers on ppc64 will generate a toc-entry for the global and a got-indirect access using that toc-entry (as if it were a .got entry)
For example the following C code
extern int aGlobal;
int foo(void) {
return aGlobal;
}
would get translated to:
addis 3, 2, .LC0 at toc@ha
ld 3, .LC0 at toc@l(3)
lwa 3, 0(3)
...
.section .toc,"aw", at progbits
.LC0:
.tc aGlobal[TC],aGlobal
Where `.LC0 at toc` is the offset from the TOC base-pointer to the label .LC0, and ` .tc aGlobal[TC],aGlobal` creates an entry in the .toc section to store the address of `aGlobal`.
The first 2 instructions build the address of the toc-entry and load the address of aGlobal into r3, while the following `lwa` instruction loads the value of the global into r3.
If the global being accessed is a non-preemptable definition and the offset from the TOC pointer to the definition can be materialized with 2 instructions then we can relax the first 2 instructions to add that offset to the TOC base pointer rather then loading the address out of the .toc.
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D54720
Files:
ELF/Arch/PPC64.cpp
ELF/Arch/X86_64.cpp
ELF/InputSection.cpp
ELF/Relocations.cpp
ELF/Relocations.h
ELF/Target.cpp
ELF/Target.h
test/ELF/Inputs/ppc64-global.s
test/ELF/Inputs/ppc64-local.s
test/ELF/ppc64-func-entry-points.s
test/ELF/ppc64-got-indirect.s
test/ELF/ppc64-relocs.s
test/ELF/ppc64-toc-relax-jumptable.s
test/ELF/ppc64-toc-relax.s
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54720.174670.patch
Type: text/x-patch
Size: 21023 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181119/2508cba5/attachment.bin>
More information about the llvm-commits
mailing list