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]

define "internal" visibility for i386


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.


r~


        * config/i386/i386.h (ix86_expand_prologue): Do not emit pic register
        load if "internal" visibility.
        * doc/extend.texi: Document visibility meanings.

Index: doc/extend.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/extend.texi,v
retrieving revision 1.66
diff -c -p -d -r1.66 extend.texi
*** extend.texi	2002/02/27 18:47:51	1.66
--- extend.texi	2002/03/03 05:17:52
*************** f () @{ /* @r{Do something.} */; @}
*** 2218,2223 ****
--- 2218,2248 ----
  int i __attribute__ ((visibility ("hidden")));
  @end smallexample
  
+ See the ELF gABI for complete details, but the short story is
+ 
+ @table @dfn
+ @item hidden
+ Hidden visibility indicates that the symbol will not be placed into
+ the dynamic symbol table, so no other @dfn{module} (executable or
+ shared library) can reference it directly.
+ 
+ @item protected
+ Protected visibility indicates that the symbol will be placed in the
+ dynamic symbol table, but that references within the defining module
+ will bind to the local symbol.  That is, the symbol cannot be overridden
+ by another module.
+ 
+ @item internal
+ Internal visibility is like hidden visibility, but with additional
+ processor specific semantics.  Unless otherwise specified by the psABI,
+ gcc defines internal visibility to mean that the function is @emph{never}
+ called from another module.  Note that hidden symbols, while then cannot
+ be referenced directly by other modules, can be referenced indirectly via
+ function pointers.  By indicating that a symbol cannot be called from
+ outside the module, gcc may for instance omit the load of a PIC register
+ since it is known that the calling function loaded the correct value.
+ @end table
+ 
  Not all ELF targets support this attribute.
  
  @item regparm (@var{number})
Index: config/i386/i386.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.c,v
retrieving revision 1.369
diff -c -p -d -r1.369 i386.c
*** i386.c	2002/02/27 00:29:00	1.369
--- i386.c	2002/03/03 05:17:55
*************** ix86_expand_prologue ()
*** 4184,4190 ****
  #endif
  
    if (pic_reg_used)
!     load_pic_register ();
  
    /* If we are profiling, make sure no instructions are scheduled before
       the call to mcount.  However, if -fpic, the above call will have
--- 4184,4196 ----
  #endif
  
    if (pic_reg_used)
!     {
!       tree vis = lookup_attribute ("visibility", DECL_ATTRIBUTES (cfun->decl));
!       if (!vis
! 	  || strcmp ("internal",
! 		     TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (vis)))))
!         load_pic_register ();
!     }
  
    /* If we are profiling, make sure no instructions are scheduled before
       the call to mcount.  However, if -fpic, the above call will have


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