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: [IFUNC] PATCH: Add an ifunc attribute


On Wed, Jul 01, 2009 at 11:07:16PM -0700, Mark Mitchell wrote:
> Richard Guenther wrote:
> 
> >> When using asm to change C++ symbol name, you have to mangle it
> >> by hand. When you change the prototype of the ifunc function,
> >> you have to mangle the symbol name again.  Should we ask gcc
> >> users which approach is better?
> > 
> > No.
> 
> Richard, I disagree with your position in this thread.  In particular, I
> do think that we should try to make this attribute work for C++ without
> users having to do by-hand mangling of names.  That's clearly the right
> user interface; C++ programmers should never have to know about mangling.

If mangling is the issue, then just allow asm and alias attribute to specify
decl for mangling, as alternative to the current string.  That would help
not only using asm with ifunc attribute, but also other asms used for symbol
redirection and the alias attribute.  Currently in C++, if you want to have
both foo and bar implemented by the same routine, you need to write:

void
foo (int)
{
}

__typeof (foo) bar __attribute__((alias ("_Z3fooi")));
__typeof (foo) baz __attribute__((alias ("_Z3fooi")));

If we had:
void
foo (int)
{
}

__typeof (foo) bar __attribute__((alias (mangle (foo))));
__typeof (::foo) baz __attribute__((alias (mangle (::foo))));

Or

int foo (int, long);
static int foo1 (int x, long y) { return x + y; }
static int foo2 (int x, long y) { return x - y; }
__typeof (foo) *foo_ifunc (void) __asm (mangle (foo))
{
  if (cpuid & have_ADD)
    return foo1;
  return foo2;
}

I'd say keep the extensions simple, well defined, and let the users stack
them if they need it the way they want.  Changing the return type and
arguments from prototype looks like very non-obvious extension and one that
will cause a can of worms in GCC for years.

	Jakub


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