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

Joerg Sonnenberger via llvm-commits llvm-commits at lists.llvm.org
Sat May 7 11:52:47 PDT 2016


On Sat, May 07, 2016 at 10:58:51AM -0700, Xinliang David Li via llvm-commits wrote:
> To be clear, assuming copyrelocs (support in linker) allows compiler to
> generate efficient code (speculatively) to access external globals which
> compiler has no idea where they are going to be defined. For most of the
> cases, the most of globals end up in the main program, so copyrelocs is
> only a fallback mechanism in case that is not the case.

I think your reasoning is confusing cause and effect. Copy relocations
exist, because people didn't want to change things when shared linkage
was introduced. It is a horrible hack and everyone seriously involved
with ELF acknowledges that it is a horrible hack only comparible to text
relocations. There are cleaner ways to address the problem for PIE
without readding this nightmare. You can mark symbols as hidden. You can
mark symbols as protected. Both can allow better code generation. The
reduced register pressure is a myth IMO, the difference between a GOT
load and a direct reference to a symbol for PIC and PIE is being able to
fold an index computation. That's it.

Joerg


More information about the llvm-commits mailing list