From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5393 invoked by alias); 6 Nov 2012 18:17:00 -0000 Received: (qmail 5379 invoked by uid 22791); 6 Nov 2012 18:16:59 -0000 X-SWARE-Spam-Status: No, hits=-5.5 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; Tue, 06 Nov 2012 18:16:54 +0000 Received: by mail-oa0-f47.google.com with SMTP id h1so736321oag.20 for ; Tue, 06 Nov 2012 10:16:53 -0800 (PST) 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-gm-message-state; bh=Tqc2rjUYlzXR77jBjWLYj8MPOwZbxPriI7Kdd68QJgg=; b=gfpD8oNXEiAIe4iCjStOjh6PeLHmosZ7acSxNqa0aVLw0JA/R0yvkw1hXyP29SpLjM +J3JOP6Bp0Jc7fMFdGCpcF3KGMA6uiPGy8FOV7pFXYtdsD8m7sNxYQH646On6YupZDKq DHNEfG6nr9Zcp4aijZFe7pDXhlRcCR6gRBB6ehVRj9Y7EA20DrAxRQBwSo3xzvksdZTb c0QhKDwdTNbpKuyzKCKsUaO+qM/4cvBAPI54o9uWKsg9m6NBLTGPTR3NNqi9qh7LbiLC dCSzMg1O/aEOmx1R9jk+UToXiHipMOcXSLC7dj7SX+wqDfrhsL8yvaecn7tcbd8hJnfR u0/A== MIME-Version: 1.0 Received: by 10.182.38.101 with SMTP id f5mr1546968obk.80.1352225813598; Tue, 06 Nov 2012 10:16:53 -0800 (PST) Received: by 10.182.176.106 with HTTP; Tue, 6 Nov 2012 10:16:53 -0800 (PST) In-Reply-To: <50993222.3010609@redhat.com> References: <5008708E.1030109@redhat.com> <506F27AF.3070805@redhat.com> <50816D63.3020908@google.com> <20121026155447.GA4348@atrey.karlin.mff.cuni.cz> <50902624.3020705@redhat.com> <50912F66.3030707@redhat.com> <50993222.3010609@redhat.com> Date: Tue, 06 Nov 2012 18:17:00 -0000 Message-ID: Subject: Re: User directed Function Multiversioning via Function Overloading (issue5752064) From: Sriraman Tallam To: Jason Merrill Cc: David Li , "H.J. Lu" , gcc-patches List , Jan Hubicka , Diego Novillo Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQlY9+P5FFwBRbXMNFOFvVUnG0t6bUVyWDtzeZWrd3jn7vLSfWfiBlsgZ1Cb0PpZfnETsoFQTpZ/Jn0eZ75XrrHT1trpkMfiJjMLbPmR/BgIw5VWqjNXw6P2vdSoArJFjW2vncXAsC1v3L/WnWwhYbQGMGTZwxna1HNQ0ZVnqHyO6dcJ+wIs1nWd3KCtZH/NuVlG+o85 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-11/txt/msg00548.txt.bz2 On Tue, Nov 6, 2012 at 7:52 AM, Jason Merrill 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 >