From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29956 invoked by alias); 29 Oct 2012 12:55:23 -0000 Received: (qmail 29945 invoked by uid 22791); 29 Oct 2012 12:55:23 -0000 X-SWARE-Spam-Status: No, hits=0.7 required=5.0 tests=AWL,BAYES_50,KHOP_BIG_TO_CC,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,TW_CF,TW_FN X-Spam-Check-By: sourceware.org Received: from atrey.karlin.mff.cuni.cz (HELO atrey.karlin.mff.cuni.cz) (195.113.26.193) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 29 Oct 2012 12:55:18 +0000 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 4018) id C277BF056F; Mon, 29 Oct 2012 13:55:15 +0100 (CET) Date: Mon, 29 Oct 2012 13:05:00 -0000 From: Jan Hubicka To: Sriraman Tallam Cc: Jan Hubicka , 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 Subject: Re: User directed Function Multiversioning via Function Overloading (issue5752064) Message-ID: <20121029125515.GH3200@atrey.karlin.mff.cuni.cz> References: <506F27AF.3070805@redhat.com> <50816D63.3020908@google.com> <20121026155447.GA4348@atrey.karlin.mff.cuni.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) 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/msg02584.txt.bz2 > 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. 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