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: Jason Merrill <jason at redhat dot com>
- Cc: David Li <davidxl at google dot com>, "H.J. Lu" <hjl dot tools at gmail dot com>, gcc-patches List <gcc-patches at gcc dot gnu dot org>, Jan Hubicka <jh at suse dot cz>, Diego Novillo <dnovillo at google dot com>
- Date: Tue, 6 Nov 2012 10:16:53 -0800
- Subject: Re: User directed Function Multiversioning via Function Overloading (issue5752064)
- References: <CAAs8HmxHF38ktt6syjWp-MpjiX+6NcXh7_8Xn6iKnAiF2vRymQ@mail.gmail.com> <5008708E.1030109@redhat.com> <CAAs8Hmy7h5SGkJ+D5v_DnXs-h4B2d_YWEcstufb5=SowbVBp0Q@mail.gmail.com> <CAAs8HmyKPG_LxxxP2ngkGTFAKUPXQDJsbbsrOB_oAP0ViyER3g@mail.gmail.com> <506F27AF.3070805@redhat.com> <CAAs8HmxEod=EJNyUjrD0-WaP0-cB5o_AN9oc2O2ryu--MRQf4w@mail.gmail.com> <CAAs8Hmyy9S+Ucg6rTDU3xGMg8JEaa0r3rNjbxhbjuk9H8Sb6wg@mail.gmail.com> <50816D63.3020908@google.com> <CAAs8HmzZUnGq9G3KQ-wesKOHVWJBHn1n0zyFhEOPxo+i0PBrww@mail.gmail.com> <CAAs8HmxXfBdsLOrhEnd=syUXfbo5gKa-QkdWQG=4bUeWOPrSfQ@mail.gmail.com> <20121026155447.GA4348@atrey.karlin.mff.cuni.cz> <CAAs8Hmw0KBhKp_3qe0gzVi1jw=LVg6GD1cv-++=Kh3OjThwB+A@mail.gmail.com> <50902624.3020705@redhat.com> <CAAs8Hmw09giv-5_v0irhByTjTJV=kD58rCAD2SAz7M8zrwjBOA@mail.gmail.com> <50912F66.3030707@redhat.com> <CAAs8Hmz4CNzyJHAPoRkEe5gtL3YXSqoNHGMeZdm0uJujFHkMhQ@mail.gmail.com> <CAAs8Hmz7aDcN+2YGfH8ixrgUt+A=PuTt8ZzPhUVeQTgSWGP-Ww@mail.gmail.com> <50993222.3010609@redhat.com>
On Tue, Nov 6, 2012 at 7:52 AM, Jason Merrill <jason@redhat.com> wrote:
> On 11/05/2012 09:38 PM, Sriraman Tallam wrote:
>>
>> + /* For multi-versioned functions, more than one match is just fine.
>>
>> + Call decls_match to make sure they are different because they are
>> + versioned. */
>> + if (DECL_FUNCTION_VERSIONED (fn))
>> + {
>> + for (match = TREE_CHAIN (matches); match; match = TREE_CHAIN
>> (match))
>> + if (!DECL_FUNCTION_VERSIONED (TREE_PURPOSE (match))
>> + || decls_match (fn, TREE_PURPOSE (match)))
>> + break;
>> + }
>
>
> I still don't understand what this code is supposed to be doing. Please
> remove it and instead modify the other loop to allow mismatches that are
> versions of the same function.
Ok, will do. I was trying to do for versioned functions what the other
loop was doing thought I could not come up with a test case to
exercise this code.
I will make all the other changes and get back asap.
Thanks,
-Sri.
>
>> + /* If the olddecl is a version, so is the newdecl. */
>> + if (TREE_CODE (newdecl) == FUNCTION_DECL
>> + && DECL_FUNCTION_VERSIONED (olddecl))
>> + {
>> + DECL_FUNCTION_VERSIONED (newdecl) = 1;
>> + /* newdecl will be purged and is no longer a version. */
>> + delete_function_version (newdecl);
>> + }
>
>
> Please make the comment clearer that the reason we're setting the flag on
> the newdecl is so that it'll be copied back into the olddecl; otherwise it
> seems odd to say it's a version and then it isn't a version.
>
>> + /* If a pointer to a function that is multi-versioned is requested, the
>> + pointer to the dispatcher function is returned instead. This works
>> + well because indirectly calling the function will dispatch the right
>> + function version at run-time. */
>>
>> + if (DECL_FUNCTION_VERSIONED (fn))
>> + {
>> + tree dispatcher_decl = NULL;
>> + gcc_assert (targetm.get_function_versions_dispatcher);
>> + dispatcher_decl = targetm.get_function_versions_dispatcher (fn);
>> + if (!dispatcher_decl)
>> + {
>> + error_at (input_location, "Pointer to a multiversioned function"
>> + " without a default is not allowed");
>> + return error_mark_node;
>> + }
>> + retrofit_lang_decl (dispatcher_decl);
>> + fn = dispatcher_decl;
>
>
> This code should use the get_function_version_dispatcher function in
> cp/call.c.
>
> Jason
>