From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10270 invoked by alias); 29 Oct 2012 17:38:48 -0000 Received: (qmail 10161 invoked by uid 22791); 29 Oct 2012 17:38:47 -0000 X-SWARE-Spam-Status: No, hits=-2.7 required=5.0 tests=AWL,BAYES_50,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,KHOP_BIG_TO_CC,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,RP_MATCHES_RCVD,TW_CF,TW_FN X-Spam-Check-By: sourceware.org Received: from mail-ob0-f175.google.com (HELO mail-ob0-f175.google.com) (209.85.214.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 29 Oct 2012 17:38:38 +0000 Received: by mail-ob0-f175.google.com with SMTP id eq6so5143979obc.20 for ; Mon, 29 Oct 2012 10:38:37 -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=HGzUnYbT3AyZK7U/dT5rBOwp1y9WcjdcLXL8Notm27A=; b=HihR6j5BnuICp9yE9na0ArUPS0v7eHChyk/SRWLgEx4Wvf/x7AI/qOZ3w47mUkqG43 1nF6rP3rlbveQpfXzz1Jt/ZDV1sjn+I13YKyXVlEjVoaff5ZwZjiuL6t1LPZQ6QNBHjH Ml+9L0Wa1jWRk9Nm+Zhl6TaYmHxhbCNb9AaFSzHyDviMzbgulH/rgVAZ8ZCMmwsQvGQL 3/7dBHar0w2/r6rMgz0xR4rHoMY9QQuz3O14LrYYHkFsZyhPe7bk4n4HW3e/kYHdInTk 9JYc1qylJzaN0EwSVLMgZ24qgnt1pmH3lTGapqpbmiVglUdSTerA/1dMQTczon8Rc2pn nINw== MIME-Version: 1.0 Received: by 10.182.188.36 with SMTP id fx4mr1378964obc.6.1351532317319; Mon, 29 Oct 2012 10:38:37 -0700 (PDT) Received: by 10.182.176.106 with HTTP; Mon, 29 Oct 2012 10:38:36 -0700 (PDT) In-Reply-To: <20121029125515.GH3200@atrey.karlin.mff.cuni.cz> References: <506F27AF.3070805@redhat.com> <50816D63.3020908@google.com> <20121026155447.GA4348@atrey.karlin.mff.cuni.cz> <20121029125515.GH3200@atrey.karlin.mff.cuni.cz> Date: Mon, 29 Oct 2012 17:56:00 -0000 Message-ID: Subject: Re: User directed Function Multiversioning via Function Overloading (issue5752064) From: Sriraman Tallam To: Jan Hubicka Cc: Diego Novillo , Jason Merrill , Jan Hubicka , Xinliang David Li , Mark Mitchell , Nathan Sidwell , "H.J. Lu" , Richard Guenther , 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: ALoCoQnBfXnzLnVjlVOIcJi7fU7UUYb2KbfWlhphWdZoFHCFhRDMV385wkjED3yT4H67vNhcqOEFIf/mfyWuceOkFdD8CjOV4gB+dbPFmQWilNV9d9VE2Bnc7bV4zM7amzFksElOBG3dBJpL92MEE0XlDTq9LJ/vuDdNbdVDS5Z1sA1njqdkxvDaKpxIwvTVt8lRXQmT2aM7 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/msg02637.txt.bz2 On Mon, Oct 29, 2012 at 5:55 AM, Jan Hubicka wrote: >> Index: gcc/cgraph.c >> =================================================================== >> --- gcc/cgraph.c (revision 192623) >> +++ gcc/cgraph.c (working copy) >> @@ -132,6 +132,74 @@ static GTY(()) struct cgraph_edge *free_edges; >> /* Did procss_same_body_aliases run? */ >> bool same_body_aliases_done; >> >> +/* Map a cgraph_node to cgraph_function_version_info using this htab. >> + The cgraph_function_version_info has a THIS_NODE field that is the >> + corresponding cgraph_node.. */ >> +htab_t GTY((param_is (struct cgraph_function_version_info *))) >> + cgraph_fnver_htab = NULL; > > I think you want declare the htab static and arrange it to be freed after > cgraph construction, so you don't need to take care of nodes being removed > via the hooks. I will declare the htab static but I want this htab for later optimizations, like dispatch hoisting. Please see: http://gcc.gnu.org/ml/gcc-patches/2011-04/msg02285.html for a description of the optimization. IFUNC based dispatch blocks inlining of multi-versioned functions and dispatch hoisting will help with this. I will make the other changes asap. Thanks, -Sri. > > OK with this change. > > I have few other comments: >> + /* IFUNC resolvers have to be externally visible. */ >> + TREE_PUBLIC (decl) = 1; >> + DECL_UNINLINABLE (decl) = 1; > > Why the resolvers can not be inlined? >> + >> + DECL_EXTERNAL (decl) = 0; >> + DECL_EXTERNAL (dispatch_decl) = 0; >> + >> + DECL_CONTEXT (decl) = NULL_TREE; >> + DECL_INITIAL (decl) = make_node (BLOCK); >> + DECL_STATIC_CONSTRUCTOR (decl) = 0; >> + TREE_READONLY (decl) = 0; >> + DECL_PURE_P (decl) = 0; > > I think those can be copied from the functions you are resolving. (well as well > as many attributes and properties) >> + >> + if (DECL_COMDAT_GROUP (default_decl)) >> + { >> + DECL_COMDAT (decl) = DECL_COMDAT (default_decl); >> + make_decl_one_only (decl, DECL_COMDAT_GROUP (default_decl)); >> + } >> + else if (TREE_PUBLIC (default_decl)) >> + { >> + /* In this case, each translation unit with a call to this >> + versioned function will put out a resolver. Ensure it >> + is comdat to keep just one copy. */ >> + DECL_COMDAT (decl) = 1; >> + make_decl_one_only (decl, DECL_ASSEMBLER_NAME (decl)); >> + } >> + /* Build result decl and add to function_decl. */ >> + t = build_decl (UNKNOWN_LOCATION, RESULT_DECL, NULL_TREE, ptr_type_node); >> + DECL_ARTIFICIAL (t) = 1; >> + DECL_IGNORED_P (t) = 1; >> + DECL_RESULT (decl) = t; >> + >> + gimplify_function_tree (decl); >> + push_cfun (DECL_STRUCT_FUNCTION (decl)); >> + gimple_register_cfg_hooks (); >> + init_empty_tree_cfg_for_function (DECL_STRUCT_FUNCTION (decl)); >> + cfun->curr_properties |= >> + (PROP_gimple_lcf | PROP_gimple_leh | PROP_cfg | PROP_ssa >> + | PROP_gimple_any); >> + cfun->curr_properties = 15; >> + new_bb = create_empty_bb (ENTRY_BLOCK_PTR); >> + make_edge (ENTRY_BLOCK_PTR, new_bb, EDGE_FALLTHRU); >> + make_edge (new_bb, EXIT_BLOCK_PTR, 0); >> + *empty_bb = new_bb; > > You can simplify this by init_lowered_empty_function. > > Honza