[PATCH] D19995: Optimize access to global variable references in PIE mode when linker supports copy relocations for PIE

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Tue May 10 07:12:59 PDT 2016


On 9 May 2016 at 23:13, Sriraman Tallam <tmsriram at google.com> wrote:
> On Mon, May 9, 2016 at 4:42 PM, Reid Kleckner via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
>> On Mon, May 9, 2016 at 3:49 PM, Rafael EspĂ­ndola
>> <llvm-commits at lists.llvm.org> wrote:
>>> > Both preemtable and extern_local sound like great ideas, but how should we tell the compiler to generate copy relocations for a declaration of a GV?
>>>
>>> That is extern_local. That tells llc to assume the symbol is local.
>>> Not from the example that it produces "leaq a(%rip), %rax", which will
>>> create a copy relocation is the assumption in wrong.
>>
>> OK, so your proposal is essentially to create a linkage that tells the
>> compiler that it doesn't need to do GOT loads (or @PLT references) for
>> a symbol. The user is in some sense promising that the symbol
>> definition will be part of the current TU's DSO. If the user fails to
>> deliver on that promise, then it is a policy decision for the linker
>> to either smooth things over with a copy relocation or emit an error.
>
> Sorry, how is this any different from what exists right now with
> non-PIE and what will happen with PIE and this patch?

Two main things:

* Preemption is fully supported. Currently optimizers think that there
is no preemption, but codegen then uses a got.
* It is a per symbol property. So it will work naturally with the
linker and "internalization" in LTO. In quotes because then it will
also be doing optimizations like just removing preemptable, but not
actually internalizing.

Cheers,
Rafael


More information about the llvm-commits mailing list