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: User directed Function Multiversioning via Function Overloading (issue5752064)


On Fri, Apr 27, 2012 at 7:53 AM, Sriraman Tallam <tmsriram@google.com> wrote:
> On Fri, Apr 27, 2012 at 7:38 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Fri, Apr 27, 2012 at 7:35 AM, Sriraman Tallam <tmsriram@google.com> wrote:
>>> On Fri, Apr 27, 2012 at 6:38 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>> On Thu, Apr 26, 2012 at 10:08 PM, Sriraman Tallam <tmsriram@google.com> wrote:
>>>>> Hi,
>>>>>
>>>>> ? I have made the following changes in this new patch which is attached:
>>>>>
>>>>> * Use target attribute itself to create function versions.
>>>>> * Handle any number of ISA names and arch= ?args to target attribute,
>>>>> generating the right dispatchers.
>>>>> * Integrate with the CPU runtime detection checked in this week.
>>>>> * Overload resolution: If the caller's target matches any of the
>>>>> version function's target, then a direct call to the version is
>>>>> generated, no need to go through the dispatching.
>>>>>
>>>>> Patch also available for review here:
>>>>> http://codereview.appspot.com/5752064
>>>>>
>>>>
>>>> Does it work with
>>>>
>>>> int foo ();
>>>> int foo () __attribute__ ((targetv("arch=corei7")));
>>>>
>>>> int (*foo_p) () = foo?
>>>
>>> Yes, this will work. foo_p will be the address of the dispatcher
>>> function and hence doing (*foo_p)() will call the right version.
>>
>> Even when foo_p is a global variable and compiled with -fPIC?
>
> I am not sure I understand what the complication is here, but FWIW, I
> tried this example and it works
>
> int foo ()
> {
> ?return 0;
> }
>
> int ?__attribute__ ((target ("arch=corei7)))
> foo ()
> {
> ?return 1;
> }
>
> int (*foo_p)() = foo;
> int main ()
> {
> ?return (*foo_p)();
> }
>
> g++ -fPIC -O2 example.cc
>
>
> Did you have something else in mind? Could you please elaborate if you
> a have a particular case in mind.
>

That is what I meant.  But I didn't see it in your testcase.
Can you add it to your testcase?

Also you should verify the correct function is called in
your testcase at run-time.


Thanks.


-- 
H.J.


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