On Fri, Oct 5, 2012 at 10:43 AM, Jason Merrill <ja...@redhat.com> wrote:
> On 08/24/2012 08:34 PM, Sriraman Tallam wrote:
>>
>> +  /* If the address of a multiversioned function dispatcher is taken,
>> +     generate the body to dispatch the right function at run-time.  This
>>
>> +     is needed as the address can be used to do an indirect call.  */
>
>
> It seems to me that you don't need a dispatcher for doing indirect calls;
> you could just take the address of the version you would choose if you were
> doing a direct call.
>
> The only reason for a dispatcher I can think of is if you want the address
> of a function to compare equal across translation units compiled with
> different target flags.  I'm not sure that's necessary; am I missing
> something?

In general, the dispatcher is always necessary since it is not known
what function version will be called at compile time. This is true
whether it is a direct or an indirect call.

Example:
int foo() __attribute__(sse3)
{
}

int foo () __attribute__(sse4)
{
}

int main ()
{
   foo (); // The version of foo to be called is not known at compile
time. Needs dispatcher.
   int (*p)() = &foo; // What should be the value of p?
   (*p)(); // This needs a dispatcher too.
}

Now, since a dispatcher is necessary when the address of the function
is taken, I thought I could as well make it the address of the
function.

Thanks,
-Sri.

>
> Continuing to look at the patch.
>
> Jason
>

Reply via email to