linux-mips
[Top] [All Lists]

Re: mips RDHWR instruction in glibc

To: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Subject: Re: mips RDHWR instruction in glibc
From: Daniel Jacobowitz <dan@debian.org>
Date: Thu, 15 Jun 2006 11:32:52 -0400
Cc: libc-ports@sourceware.org, linux-mips@linux-mips.org
In-reply-to: <20060616.002837.59465125.anemo@mba.ocn.ne.jp>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <20060615.001238.65193088.anemo@mba.ocn.ne.jp> <20060614165040.GA19480@nevyn.them.org> <20060616.002837.59465125.anemo@mba.ocn.ne.jp>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mutt/1.5.11+cvs20060403
On Fri, Jun 16, 2006 at 12:28:37AM +0900, Atsushi Nemoto wrote:
> On Wed, 14 Jun 2006 12:50:40 -0400, Daniel Jacobowitz <dan@debian.org> wrote:
> > > For example, in the code below, RDHWR is placed _before_ checking the
> > > error.  I suppose these instructions were reordered by gcc's
> > > optimization, but the optimization would have large negative effect in
> > > this case.
> > 
> > You'd have to figure out how to get GCC not to eagerly schedule the
> > rdhwr.  This might be quite hard.  I don't know much about this part of
> > the scheduler.
> 
> I really did not understand yet how errno is bound TLS.  I found some
> "rdhwr" in glibc-ports source code (tls-macros.h, nptl/tls.h).  The
> RDHWR instruction in the example code comes from one of them, no?

No.

> I also found a "rdhwr" in gcc's mips.md file ("tls_get_tp_<mode>").
> Is this the origin?  MD is a very foreign language for me...

Yes.  Compile something like this with -O2 but without -fpic:

__thread int x;
int foo() { return x; }

It should use the IE model, which will generate a rdhwr.

-- 
Daniel Jacobowitz
CodeSourcery

<Prev in Thread] Current Thread [Next in Thread>