From patchwork Mon Nov 14 17:34:50 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 125572 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 5D414B71FF for ; Tue, 15 Nov 2011 04:35:08 +1100 (EST) Received: (qmail 23019 invoked by alias); 14 Nov 2011 17:35:06 -0000 Received: (qmail 22818 invoked by uid 22791); 14 Nov 2011 17:35:05 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 14 Nov 2011 17:34:51 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 88A079AC723; Mon, 14 Nov 2011 18:34:50 +0100 (CET) Date: Mon, 14 Nov 2011 18:34:50 +0100 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Fix emutls bootstrap issues Message-ID: <20111114173450.GA31042@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi, emutls is creating variables late that confuses varpool since varpool_finalize_decl is supposed to be used only before cgraph construction. This patch fixes the problem by introducing varpool_add_new_variable that works same as cgraph_add_new_function (i.e. allows middle-end/back-end to create new variables after varpool construction). Bootstrapped/regtested x86_64-linux, comitted. 2011-11-14 Jan Hubicka PR middle-end/50598 * cgraph.h (varpool_externally_visible_p): Declare. (varpool_add_new_variable): Declare. * tree-emultls.c (get_emutls_init_templ_addr, new_emutls_decl): Use varpool_add_new_variable. * ipa.c (varpool_externally_visible_p): Export. * varpool.c (varpool_add_new_variable): New function. Index: cgraph.h =================================================================== --- cgraph.h (revision 181310) +++ cgraph.h (working copy) @@ -641,6 +641,7 @@ void debug_varpool_node_set (varpool_nod void free_varpool_node_set (varpool_node_set); void ipa_discover_readonly_nonaddressable_vars (void); bool cgraph_comdat_can_be_unshared_p (struct cgraph_node *); +bool varpool_externally_visible_p (struct varpool_node *, bool); /* In predict.c */ bool cgraph_maybe_hot_edge_p (struct cgraph_edge *e); @@ -681,6 +682,7 @@ bool const_value_known_p (tree); bool varpool_for_node_and_aliases (struct varpool_node *, bool (*) (struct varpool_node *, void *), void *, bool); +void varpool_add_new_variable (tree); /* Walk all reachable static variables. */ #define FOR_EACH_STATIC_VARIABLE(node) \ Index: tree-emutls.c =================================================================== --- tree-emutls.c (revision 181310) +++ tree-emutls.c (working copy) @@ -262,7 +262,7 @@ get_emutls_init_templ_addr (tree decl) if (DECL_EXTERNAL (to)) varpool_node (to); else - varpool_finalize_decl (to); + varpool_add_new_variable (to); return build_fold_addr_expr (to); } @@ -334,7 +334,7 @@ new_emutls_decl (tree decl, tree alias_o if (DECL_EXTERNAL (to)) varpool_node (to); else if (!alias_of) - varpool_finalize_decl (to); + varpool_add_new_variable (to); else varpool_create_variable_alias (to, varpool_node_for_asm Index: ipa.c =================================================================== --- ipa.c (revision 181310) +++ ipa.c (working copy) @@ -647,7 +647,7 @@ cgraph_externally_visible_p (struct cgra /* Return true when variable VNODE should be considered externally visible. */ -static bool +bool varpool_externally_visible_p (struct varpool_node *vnode, bool aliased) { if (!DECL_COMDAT (vnode->decl) && !TREE_PUBLIC (vnode->decl)) Index: varpool.c =================================================================== --- varpool.c (revision 181310) +++ varpool.c (working copy) @@ -414,6 +414,20 @@ varpool_finalize_decl (tree decl) varpool_assemble_pending_decls (); } +/* Add the variable DECL to the varpool. + Unlike varpool_finalize_decl function is intended to be used + by middle end and allows insertion of new variable at arbitrary point + of compilation. */ +void +varpool_add_new_variable (tree decl) +{ + struct varpool_node *node; + varpool_finalize_decl (decl); + node = varpool_node (decl); + if (varpool_externally_visible_p (node, false)) + node->externally_visible = true; +} + /* Return variable availability. See cgraph.h for description of individual return values. */ enum availability