This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [rs6000] Don't emit libcall notes around TLS address
On Wednesday 15 June 2005 01:33, Richard Henderson wrote:
> On Wed, Jun 15, 2005 at 12:22:13AM +0200, Steven Bosscher wrote:
> > ... or did you have something completely different in mind?
>
> How about something completely different.
>
> One new builtin, __builtin_tls_ld_base(); void* result.
>
> One new TLS_ADDR_EXPR, with two operands. The first operand is
> a VAR_DECL node, and is the second is either:
>
> (1) zero, i.e. unused, in the case the var_decl is global-dynamic.
>
> (2) a register, the result of __builtin_tls_ld_base, in the case
> the var_decl is local-dynamic.
>
> The type of the TLS_ADDR_EXPR would be correct as for an ADDR_EXPR.
> The node itself would not be propagated into any of the INDIRECT_REF
> nodes, and so we get the cse'ing that we want.
It doesn't work very well with structures, though.
Consider this:
typedef struct { int a, b; } X;
extern __thread X *x, *y;
int foo (void) { *x = *y; }
which would give us the following when we'd split up TLS
references where necessary (in this case global-dynamic, say):
foo ()
{
struct X **t1;
struct X *t2;
struct X **t3;
struct X *t4;
struct X t5;
t1 = TLS_ADDR_EXPR<x, 0>;
t2 = *t1;
t3 = TLS_ADDR_EXPR<y, 0>;
t4 = *t3;
t5 = *t4;
*t2 = t5;
}
Note the extra structure copy with t5 :-(
You'd want "*t2 = *t4" but that is not valid GIMPLE.
Gr.
Steven