Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 7 Aug 2013 22:56:53 +0200
From:      Jilles Tjoelker <jilles@stack.nl>
To:        Dimitry Andric <dim@freebsd.org>
Cc:        "svn-src-head@FreeBSD.org" <svn-src-head@freebsd.org>, Matthew Fleming <mdf@freebsd.org>, "svn-src-all@FreeBSD.org" <svn-src-all@freebsd.org>, "src-committers@FreeBSD.org" <src-committers@freebsd.org>
Subject:   Re: svn commit: r253802 - head/contrib/llvm/tools/clang/lib/Headers
Message-ID:  <20130807205653.GB4918@stack.nl>
In-Reply-To: <2DE35C45-B110-4D93-BFA7-542A3D1EE902@freebsd.org>
References:  <201307301233.r6UCXLT8012177@svn.freebsd.org> <CAMBSHm8xDvWsKJiLAzPF8azMKLHq3WWWQ3X1d6-6nJSAppux9Q@mail.gmail.com> <2DE35C45-B110-4D93-BFA7-542A3D1EE902@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Jul 30, 2013 at 04:16:58PM +0200, Dimitry Andric wrote:
> Upstream gcc checks this with:

> #if defined(__i386__) && defined(__PIC__)
> ...
> #elif defined(__x86_64__) && (defined(__code_model_medium__) || defined(__code_model_large__)) && defined(__PIC__)
> ...

> and it exchanges ebx or rbx with %k1 or %q1, respectively, instead of
> push/pop.  That might be a little more efficient.

> I guess the defined(__PIC__) should be enough for us, in most cases.
> The code_model stuff is for x32 support, which we do not have yet.

The code_model stuff is not for x32 support but for PIC/PIE code where
code+data exceed 2GB so relative addressing cannot always be used. The
ABI then prescribes that %r15 be loaded with the GOT pointer when
invoking a large model (code>2GB) PLT entry; otherwise (medium model or
no PLT entry used), much like i386, any register can be used for the GOT
pointer.

In x32, relative addressing can always be used and there is no need for
a PIC register.

I don't really understand why special tricks are needed for %ebx/%rbx.
With the "b" constraint or "%ebx" clobber, adequate information is
provided to the compiler that %ebx/%rbx will have to be saved somewhere
around the asm. And in fact this appears to work fine with clang; only
gcc (4.2.1 and 4.4.3; I have not tested newer versions) needs special
trickery to access %ebx.

-- 
Jilles Tjoelker



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130807205653.GB4918>