This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH/RFA] SH TLS support

kaz Kojima wrote:
> I could add an explanation for that implementation which looks oddly
> inefficient. Sorry for this.
> I once implemented a similer TLS code generation as you say. The problem
> is that we need linker optimization like:
>         mov.l   .Ln, r4         ->      mov.l   .Ln, r0
>         mova    .Lf, r0         ->      stc     gbr, r4
>         mov.l   .Lf, r1         ->      mov.l   @(r0,r12), r0
>         add     r0, r1          ->      add     r4, r0
>         jsr     @r1             ->      nop
>         add     r12, r4         ->      nop
>         ...
> .Ln:    .long   x at TLSGD         ->      .long   x at GOTTPOFF
> .Lf:    .long   __tls_get_addr at PLT
> (an example GD -> IE transition) and we have to find instructions from
> the constant pools containing TLS relocation or special function symbol
> __tls_get_addr.

How often (as a percentage of TLS references) is this linker relaxation
performed with typical code?  We want to make sure that the cost for this
pessimal pre-relaxation version is less than what we gain by the relaxation.
Moreover, it appears you still have a branch around a tiny bit of data
in the relaxed version.  If we can at least stick the reference for x into
the constant pool, this can go away.

When we use a magic code sequence, there should also be a comment in
to that effect and how it is expected to be transformed.

> That implementation used a heuristic algorithm in assembler and many new
> reloc types to mark instructions found as the TLS code. But it was very
> fragile from compiler optimizations and many marker relocation types were
> ugly and seemed to waste ELF relocation numbers. So I changed to use a
> fixed instruction sequences for global and local dynamic cases according
> to Uli's suggestion. It makes TLS stuff in assembler and linker very
> simple and stable and removes the marker relocations.

The basic SH linker relaxation has been broken since the PIC code was
introduced.  I had a go at this a few days ago, but while it looks like
I fixed the switch relocations, the relocations for ordinary branches are
still not right.  And of course it is not possible to do a meaningful test
run when you can't do ordinary branches.
Do you have patches to fix the linker relaxation?
SuperH (UK) Ltd.
2410 Aztec West / Almondsbury / BRISTOL / BS32 4QX
T:+44 1454 465658

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]