[llvm-dev] [PPC] Linker fails on -fstack-protector

Joerg Sonnenberger via llvm-dev llvm-dev at lists.llvm.org
Tue Feb 23 15:43:04 PST 2016

On Tue, Feb 23, 2016 at 04:39:50PM +0000, Tim Shen wrote:
> On Tue, Feb 23, 2016, 04:50 Joerg Sonnenberger via llvm-dev <
> llvm-dev at lists.llvm.org> wrote:
> > You can get the TCB address from %fs:0 or %gs:0 on x86. But that's
> > suboptimal for the purpose here as you need to do a second load with the
> > resulting pointer, when you could have gotten it from %fs:$magic_offset
> > or %gs:$magic_offset in first place.
> >
> Isn't LLVM already combining a register load with an offset (0) followed by
> another offset-load? If it's currently not implemented, it seems quite
> useful and generic, and we should just implmenet it?

I don't think so -- wouldn't normally make sense and the TLS access path
is explicitly lowered differently.

> If for some reason it can't be done, we can still pass the offset into the
> intrinsic, as ISD::GlobalTLSAddress is designed.
> ISD::GlobalTLSAddress is actually quite close to what we want - except for
> a GlobalValue it requires. Maybe we can make that requirement optional?
> E.g. if a nullptr is passed in as the GlobalValue, generate fs:offset,
> rather than fs:@a+ offset.

That doesn't solve the other problem I mentioned that a number of
different ways to speed up the access exists. I.e. OpenBSD duplicates
the cookie in every DSO in a hidden variable, which is comperative in
overhead on most architectures and sometimes even much cheaper than
using TLS-alike.


More information about the llvm-dev mailing list