From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22327 invoked by alias); 5 Oct 2012 21:58:03 -0000 Received: (qmail 22319 invoked by uid 22791); 5 Oct 2012 21:58:02 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-oa0-f47.google.com (HELO mail-oa0-f47.google.com) (209.85.219.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 05 Oct 2012 21:57:57 +0000 Received: by mail-oa0-f47.google.com with SMTP id h1so2491745oag.20 for ; Fri, 05 Oct 2012 14:57:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:x-system-of-record:x-gm-message-state; bh=9swl46B2kXrp3ySl7N90ldbZ0LV3eC0YB/e4+9B74rY=; b=c9b/O3rEM3iGPZL0sK2SgE37hNbGxYjKF4kzyNI52B3HQiWbLwzC0KAc8Y3zX8pcoF xMxHh5acYqJn5A49d1e8O8lSkPZa7CN26woF0nO5hNbCGmmkvhDLwmyVhghm7wkfgN5i cLNrpVrlZFl88BM7pJySO0WKp3LDe9Fse1/gUmAGT6YklIW/9KsstqVjqvWmlJ700ge5 YecyfsxgsHSki1M8bdLHj4STj31gEGFJy3JYFgvFrXOx0f4TywLl9M/qe0Y/+U+7j+bN +OGb7bw/2mJRiAnifqEdDKz1JqcM3rpUbmIolBhVvlwMFxSKfDqR9dWFegDAwgqtV564 aYaw== MIME-Version: 1.0 Received: by 10.182.52.105 with SMTP id s9mr8185968obo.25.1349474277148; Fri, 05 Oct 2012 14:57:57 -0700 (PDT) Received: by 10.182.75.74 with HTTP; Fri, 5 Oct 2012 14:57:56 -0700 (PDT) In-Reply-To: <506F1C5D.9060500@redhat.com> References: <20120307004630.A503DB21B6@azwildcat.mtv.corp.google.com> <4FF7D1C6.90407@redhat.com> <4FF96D0C.5060406@redhat.com> <4FFBF9F5.6020306@redhat.com> <5008708E.1030109@redhat.com> <506F1C5D.9060500@redhat.com> Date: Fri, 05 Oct 2012 21:58:00 -0000 Message-ID: Subject: Re: User directed Function Multiversioning via Function Overloading (issue5752064) From: Sriraman Tallam To: Jason Merrill Cc: Xinliang David Li , mark@codesourcery.com, nathan@codesourcery.com, "H.J. Lu" , Richard Guenther , Jan Hubicka , Uros Bizjak , reply@codereview.appspotmail.com, GCC Patches Content-Type: text/plain; charset=ISO-8859-1 X-System-Of-Record: true X-Gm-Message-State: ALoCoQnlAp00esDKdAGZjkF/I5SY0EIfHLuS1q+07ycymjfLc5+/aW5jiYrhrbbD2uAF1N2eVcsgFOQvMfW1uPF3cAAWXuuNcm/4HxI5h/H/Paki+fXBnnNdxhRdQZeS0JUkYE2evda2qUczklg+slnqCMROeugVczY9/ufCD0+QqR84jNNjBDIsnNKIYFPzk1KIla3Z2PDY X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2012-10/txt/msg00571.txt.bz2 On Fri, Oct 5, 2012 at 10:43 AM, Jason Merrill 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 >