This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: User directed Function Multiversioning via Function Overloading (issue5752064)
- From: Sriraman Tallam <tmsriram at google dot com>
- To: Richard Guenther <richard dot guenther at gmail dot com>
- Cc: jason at redhat dot com, mark at codesourcery dot com, nathan at codesourcery dot com, "H.J. Lu" <hjl dot tools at gmail dot com>, Jan Hubicka <jh at suse dot cz>, Uros Bizjak <ubizjak at gmail dot com>, reply at codereview dot appspotmail dot com, gcc-patches at gcc dot gnu dot org, David Li <davidxl at google dot com>
- Date: Fri, 6 Jul 2012 10:37:41 -0700
- Subject: Re: User directed Function Multiversioning via Function Overloading (issue5752064)
- References: <20120307004630.A503DB21B6@azwildcat.mtv.corp.google.com> <CAFiYyc3hy9wdB0d87D0TZX1Vj7P=oH0-ARf0rE3Z9wc+i8j8UA@mail.gmail.com> <CAAs8HmxsZPTH4VS78G9HZOGYXxEiVi90PgRrCc6gwp9de935WQ@mail.gmail.com> <CAAs8HmyeZE25B+vAp7aretL85WtPfyUuLAZNw7oFPFsUHZBtPA@mail.gmail.com> <CAMe9rOqUpYHNnHXMpVbN8nEPFcRV0Gr14j1YxA-Bx7Y0nMUu3w@mail.gmail.com> <CAAs8Hmx7OfYrNVFsVYi_BknexVFvP0hYroH7dnusu3Z86gs-CQ@mail.gmail.com> <CAMe9rOqaUNN67h64jJMugTsgrvpC7gsQx74UcKjBSGorxU0qOQ@mail.gmail.com> <CAAs8HmztTFyAO7ze2HKrfSNLOKc7rHomAuSLSKOSRQ-bkN_dgQ@mail.gmail.com> <CAMe9rOroWTs9KYo7ONfnc1aVK1pySzMfpEnF24C_ABF9TG5zhA@mail.gmail.com> <CAAs8Hmz64_myVEXaCrOQFBZgmW7wkBpuJnkkB_j=ebipuq92Tg@mail.gmail.com> <CAMe9rOr7Y-BPqEymmg7gApt1KroT_mtrqq8rvq4de_SM0J-zbQ@mail.gmail.com> <CAAs8HmznitzYwUCMB9kdv1fpHMMx2c-wg3_UYf8v+E4NJf25Pw@mail.gmail.com> <CAMe9rOrSAVZp0oiz=ocrWU0h4sLeoOF2hW0qsU-fNchCG3Umuw@mail.gmail.com> <CAAs8Hmw1Jc_cPKVN_WfLkcpPeFiF=QLkVFf4AGuk3PjNnR_GYw@mail.gmail.com> <CAMe9rOpMjFN94+pkLJGO3xUEiDgTJ8i4Rx97-oucxue6SskKMQ@mail.gmail.com> <CAAs8HmxrmBzsu6vejEhuequU0KYTDiCjg8HTxU1YuZ9wAm6PXA@mail.gmail.com> <CAMe9rOp_zzhPqYdzbJqRmLcDmcRo+fLS-RyDB6wB8K-uj8nu4Q@mail.gmail.com> <CAAs8HmwXAbwYbEaxvwA7KZx=454outzb-Cx4iifzZY9gB3Zx3w@mail.gmail.com> <CAAs8HmykJa+dM_efFRkL=7BTNQ5yzCEj1KyjKU_kTZNL2GefSQ@mail.gmail.com> <CAMe9rOoaOyQyWfVwacYmSX7RjKRJmPdHT-o3ZuTmrwa9xpqygQ@mail.gmail.com> <CAAs8HmzZkx+FfZ=fcfnfG7Z7buF5+z_GN_gA4r_a_80NUuTzdg@mail.gmail.com> <CAMe9rOrdZaTDzakgpHxXWE3hhUvR7LNO1NkUrtAJJCjTjz_mjg@mail.gmail.com> <CAAs8Hmzw=tTGLypq1GQ7cA=DFupP8VpwB5QiE+jwLcYOovV=YQ@mail.gmail.com> <CAAs8HmzF0JJWPvFzoNGMSJ7ZS1h4KmROdx29-__8Oh9yUA1=JA@mail.gmail.com> <CAAs8HmxgMMVtCd9Xc4x_wJS80YCDrVFVRWsF3-G9uYjyE0OR6w@mail.gmail.com> <CAFiYyc3X787Oe158tJ8w6sWred2J+f-PPta6p-5T+HFq2c2tRw@mail.gmail.com>
On Fri, Jul 6, 2012 at 2:14 AM, Richard Guenther
<richard.guenther@gmail.com> wrote:
>
> On Thu, Jun 14, 2012 at 10:13 PM, Sriraman Tallam <tmsriram@google.com> wrote:
> > +cc c++ front-end maintainers
> >
> > Hi,
> >
> > C++ Frontend maintainers, Could you please take a look at the
> > front-end part when you find the time?
>
> So you have (for now?) omitted the C frontend change(s)?
Yes, for now. I thought I will get the C++ changes and associated
middle-end checked in first. The C changes should be easy to add, I
have to introduce a new attribute for this. So, the C front-end should
look like this:
int foo (); // default version.
int foo_sse4() __attribute__ ((version("foo"), target("sse4.2"))); //
A version of foo.
and the call will be to foo.
The version attribute will be the new one, there may be an existing
attribute that I could use too for this purpose. I was thinking if the
"alias" attribute along with the "target" attribute could be used for
this purpose but it makes things unnecessarily complicated. What do
you think?
>
> > Honza, your thoughts on the callgraph part?
> >
> > Richard, any further comments/feedback?
>
> Overall I like it - the cgraph portions need comments from Honza and the
> C++ portions from a C++ maintainer though.
>
> I would appreciate a C version, too.
Sure, I will get to it immediately after the current patch reaches a
stable point.
>
> As you are tackling the C++ frontend first you should add some C++
> specific testcases - if only to verify you properly reject cases you do not
> or can not implement. Like eventually
Sure, I will add these test cases.
Thanks for reviewing,
-Sri.
>
> class Foo {
> virtual void bar() __attribute__((target("sse")));
> virtual void bar() __attribute__((target("sse2")));
> };
>
> or
>
> template <class T>
> void bar (T t) __attribute__((target("sse")));
> template <class T>
> void bar (T t) __attribute__((target("sse2")));
> template <>
> void bar (int t);
>
> (how does regular C++ overload resolution / template specialization
> interfere with the target overloads?)
>
> Thanks,
> Richard.
>
> > Additionally, I am working on generating better mangled names for
> > function versions, along the lines of C++ thunks.
> >
> > Thanks,
> > -Sri.
> >
> > On Mon, Jun 4, 2012 at 11:59 AM, Sriraman Tallam <tmsriram@google.com> wrote:
> >> Hi,
> >>
> >> Attaching updated patch for function multiversioning which brings
> >> in plenty of changes.
> >>
> >> * As suggested by Richard earlier, I have made cgraph aware of
> >> function versions. All nodes of function versions are chained and the
> >> dispatcher bodies are created on demand while building cgraph edges.
> >> The dispatcher body will be created if and only if there is a call or
> >> reference to a versioned function. Previously, I was maintaining the
> >> list of versions separately in a hash map, all that is gone now.
> >> * Now, the file multiverison.c has some helper routines that are used
> >> in the context of function versioning. There are no new passes and no
> >> new globals.
> >> * More tests, updated existing tests.
> >> * Fixed lots of bugs.
> >> * Updated patch description.
> >>
> >> Patch attached. Patch also available for review at
> >> http://codereview.appspot.com/5752064
> >>
> >> Please let me know what you think,
> >>
> >> Thanks,
> >> -Sri.
> >>
> >>
> >> On Mon, May 14, 2012 at 11:28 AM, Sriraman Tallam <tmsriram@google.com> wrote:
> >>> Hi H.J,
> >>>
> >>> Attaching new patch with 2 test cases, mv2.C checks ISAs only and
> >>> mv1.C checks ISAs and arches mixed. Right now, checking only arches is
> >>> not needed as they are mutually exclusive, any order should be fine.
> >>>
> >>> Patch also available for review here: http://codereview.appspot.com/5752064
> >>>
> >>> Thanks,
> >>> -Sri.
> >>>
> >>> On Sat, May 12, 2012 at 6:37 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> >>>> On Fri, May 11, 2012 at 7:04 PM, Sriraman Tallam <tmsriram@google.com> wrote:
> >>>>> Hi H.J.,
> >>>>>
> >>>>> I have updated the patch to improve the dispatching method like we
> >>>>> discussed. Each feature gets a priority now, and the dispatching is
> >>>>> done in priority order. Please see i386.c for the changes.
> >>>>>
> >>>>> Patch also available for review here: http://codereview.appspot.com/5752064
> >>>>>
> >>>>
> >>>> I think you need 3 tests:
> >>>>
> >>>> 1. Only with ISA.
> >>>> 2. Only with arch
> >>>> 3. Mixed with ISA and arch
> >>>>
> >>>> since test mixed ISA and arch may hide issues with ISA only or arch only.
> >>>>
> >>>> --
> >>>> H.J.