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: PATCH: PR middle-end/20297: #pragma GCC visibility isn't properly handled for builtin functions


On Fri, Mar 04, 2005 at 12:47:36PM -0700, Roger Sayle wrote:
> 
> On Fri, 4 Mar 2005, H. J. Lu wrote:
> > When do you call build_user_decl?  If user has
> >
> > #pragma GCC visibility push(hidden)
> > typedef long unsigned int size_t;
> > extern void *memcpy (void *, const void *, size_t);
> > #pragma GCC visibility pop
> >
> > shouldn't we make memcpy hidden when we emit memcpy when we fail to
> > inline __builtin_memcpy?  When we determine visibility, we have to
> > remember what user specifies.
> 
> 
> I'll let the visibility folks discuss what they want the behaviour
> to be.  However, I'll point out that for the case of changing the
> alias on a declaration, C's finish_decl explicitly calls a function
> called set_builtin_user_assembler_name in c-common.c to explicitly
> modify not only the user's FUNCTION_DECL but also the libcall's
> FUNCTION_DECL.  By default, however, changing the argument list
> or calling convention of the user-visible function does not affect
> automatically affect invocations of the __builtin_foo and/or libcall
> forms.
> 
> i.e. declaring the following at the top of your source file
> 
> extern void __fastcall memcpy(double x, double y);
> 
> doesn't by itself adversely affect GCC's ability to create an executable
> that copies large blocks of data.  Defining (or linking in) such a
> "memcpy" however...
> 

Take

#pragma GCC visibility push(default)
#pragma GCC visibility push(hidden)
typedef long unsigned int size_t;
extern void *memcpy (void *, const void *, size_t);
#pragma GCC visibility pop

__attribute__((visibility("default")))
void foo(void *dst, void *src, size_t i)
{
  memcpy(dst, src, i);
}

User wants memcpy hidden. Gcc first optimizes memcpy to
__builtin_memcpy. Then it fails to inline __builtin_memcpy and emits
memcpy at the end. Should memcpy be hidden or not? It is different
from gcc uses __builtin_memcpy to implement something else.


H.J.


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