This is the mail archive of the gcc-patches@gcc.gnu.org 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: define "internal" visibility for i386


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


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