From patchwork Sat Jan 8 16:35:47 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 77964 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 DDC37B7043 for ; Sun, 9 Jan 2011 03:36:03 +1100 (EST) Received: (qmail 24196 invoked by alias); 8 Jan 2011 16:35:58 -0000 Received: (qmail 24045 invoked by uid 22791); 8 Jan 2011 16:35:55 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, TW_BJ, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from nikam-dmz.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 08 Jan 2011 16:35:49 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 314119AC81F; Sat, 8 Jan 2011 17:35:47 +0100 (CET) Date: Sat, 8 Jan 2011 17:35:47 +0100 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: PR tree-optmization/46469 (cgraph verifier ICE) Message-ID: <20110108163547.GA28524@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, the problem here is that cgraph verifier chokes on needed inline clones. Those can be created now with extern inline functions. There is no point to drop needed flag on extern declarations, so this patch clears it in function_and_variable_visibility. For 4.7 I hope to finally move away from needed flag - it is now used only for aliases and C++ ABI weirdnesses. Bootstrapped/regtested x86_64-linux, comitted. Honza Index: ChangeLog =================================================================== --- ChangeLog (revision 168597) +++ ChangeLog (working copy) @@ -1,3 +1,9 @@ +2011-01-07 Jan Hubicka + + PR tree-optmization/46469 + * ipa.c (function_and_variable_visibility): Clear needed flags on + nodes with external decls; handle weakrefs merging correctly. + 2011-01-07 Joseph Myers * opts.c (finish_options): Set opts->x_flag_opts_finished to true, Index: ipa.c =================================================================== --- ipa.c (revision 168597) +++ ipa.c (working copy) @@ -844,16 +844,32 @@ function_and_variable_visibility (bool w IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (p->decl)), IDENTIFIER_POINTER (p->target)); - if ((node = cgraph_node_for_asm (p->target)) != NULL) + if ((node = cgraph_node_for_asm (p->target)) != NULL + && !DECL_EXTERNAL (node->decl)) { + /* Weakrefs alias symbols from other compilation unit. In the case + the destination of weakref became available because of LTO, we must + mark it as needed. */ + if (in_lto_p + && lookup_attribute ("weakref", DECL_ATTRIBUTES (p->decl)) + && !node->needed) + cgraph_mark_needed_node (node); gcc_assert (node->needed); pointer_set_insert (aliased_nodes, node); if (dump_file) fprintf (dump_file, " node %s/%i", cgraph_node_name (node), node->uid); } - else if ((vnode = varpool_node_for_asm (p->target)) != NULL) + else if ((vnode = varpool_node_for_asm (p->target)) != NULL + && !DECL_EXTERNAL (vnode->decl)) { + /* Weakrefs alias symbols from other compilation unit. In the case + the destination of weakref became available because of LTO, we must + mark it as needed. */ + if (in_lto_p + && lookup_attribute ("weakref", DECL_ATTRIBUTES (p->decl)) + && !vnode->needed) + varpool_mark_needed_node (vnode); gcc_assert (vnode->needed); pointer_set_insert (aliased_vnodes, vnode); if (dump_file) @@ -867,6 +883,8 @@ function_and_variable_visibility (bool w for (node = cgraph_nodes; node; node = node->next) { int flags = flags_from_decl_or_type (node->decl); + + /* Optimize away PURE and CONST constructors and destructors. */ if (optimize && (flags & (ECF_CONST | ECF_PURE)) && !(flags & ECF_LOOPING_CONST_OR_PURE)) @@ -875,6 +893,13 @@ function_and_variable_visibility (bool w DECL_STATIC_DESTRUCTOR (node->decl) = 0; } + /* Frontends and alias code marks nodes as needed before parsing is finished. + We may end up marking as node external nodes where this flag is meaningless + strip it. */ + if (node->needed + && (DECL_EXTERNAL (node->decl) || !node->analyzed)) + node->needed = 0; + /* C++ FE on lack of COMDAT support create local COMDAT functions (that ought to be shared but can not due to object format limitations). It is neccesary to keep the flag to make rest of C++ FE Index: testsuite/ChangeLog =================================================================== --- testsuite/ChangeLog (revision 168597) +++ testsuite/ChangeLog (working copy) @@ -1,3 +1,8 @@ +2011-01-08 Jan Hubicka + + PR tree-optmization/46469 + * g++.dg/torture/pr46469.C: New testcase. + 2011-01-08 Iain Sandoe * objc-obj-c++-shared/next-mapping.h: Move code and definitions for Index: testsuite/g++.dg/torture/pr46469.C =================================================================== --- testsuite/g++.dg/torture/pr46469.C (revision 0) +++ testsuite/g++.dg/torture/pr46469.C (revision 0) @@ -0,0 +1,13 @@ +extern "C" __inline __attribute__ ((__gnu_inline__)) int pthread_equal () + { + } + +static + __typeof + (pthread_equal) + __gthrw_pthread_equal __attribute__ ((__weakref__ ("pthread_equal"))); + +int identifierByPthreadHandle () +{ + pthread_equal (); +}