This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: define "internal" visibility for i386
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Henderson <rth at redhat dot com>, gcc-patches at gcc dot gnu dot org, Ulrich Drepper <drepper at redhat dot com>
- Date: Mon, 4 Mar 2002 11:50:11 -0500
- Subject: Re: define "internal" visibility for i386
- References: <20020302210517.A30887@redhat.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Sat, Mar 02, 2002 at 09:05:17PM -0800, Richard Henderson wrote:
> Gives a useful meaning to the processor-defined "internal"
> visibility for i386. Should be usable in e.g. glibc to
> eliminate some needless pic register loads without having
> to do whole-program analysis.
As gcc doesn't load pic register unconditionally, I cannot see how
this can work:
foo.h:
int foo (void) __attribute__((visibility("internal")));
bar.c:
#include "foo.h"
int bar (void)
{
return foo () + foo ();
}
foo.c:
#include "foo.h"
static int baz;
int foo (void)
{
return baz;
}
results in (-O2 -fpic):
bar:
pushl %ebp
movl %esp, %ebp
pushl %esi
pushl %eax
call foo
movl %eax, %esi
call foo
addl %eax, %esi
movl %esi, %eax
movl -4(%ebp), %esi
leave
ret
and
foo:
pushl %ebp
movl %esp, %ebp
pushl %ebx
movl baz@GOTOFF(%ebx), %eax
movl (%esp), %ebx
leave
ret
Here, foo meets internal visibility criteria (ie. it is never called
from other modules) but as bar is not guaranteed to actually
load pic register, this would just be pure guess work whether gcc will
have to load pic register or not.
>
> * config/i386/i386.h (ix86_expand_prologue): Do not emit pic register
> load if "internal" visibility.
> * doc/extend.texi: Document visibility meanings.
Jakub