From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12012 invoked by alias); 16 Dec 2011 10:24:07 -0000 Received: (qmail 11999 invoked by uid 22791); 16 Dec 2011 10:24:06 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 16 Dec 2011 10:23:53 +0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug lto/51573] [4.7 Regression] ICE (segfault) in lto_varpool_encoder_encode_initializer_p Date: Fri, 16 Dec 2011 10:49:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: lto X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.7.0 X-Bugzilla-Changed-Fields: CC Blocks Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-12/txt/msg01783.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51573 Richard Guenther changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dnovillo at gcc dot | |gnu.org, jason at gcc dot | |gnu.org Blocks| |48508, 48437 --- Comment #5 from Richard Guenther 2011-12-16 10:21:16 UTC --- Because of the way C++ treats things (look at PR48508) it is impossible to move fixing PRs 48508 and 48437 to the point where we handle decl merging. Thus, while Index: gcc/lto-symtab.c =================================================================== --- gcc/lto-symtab.c (revision 182398) +++ gcc/lto-symtab.c (working copy) @@ -785,6 +785,12 @@ lto_symtab_prevailing_decl (tree decl) if (TREE_CODE (decl) == FUNCTION_DECL && DECL_ABSTRACT (decl)) return decl; + /* Extern decls with function context should not be merged, they + appear in BLOCK_VARS. */ + if (DECL_EXTERNAL (decl) + && decl_function_context (decl)) + return decl; + /* Ensure DECL_ASSEMBLER_NAME will not set assembler name. */ gcc_assert (DECL_ASSEMBLER_NAME_SET_P (decl)); Index: gcc/lto/lto.c =================================================================== --- gcc/lto/lto.c (revision 182398) +++ gcc/lto/lto.c (working copy) @@ -867,9 +867,13 @@ uniquify_nodes (struct data_in *data_in, if (t == NULL_TREE) continue; - if (TREE_CODE (t) == VAR_DECL) + if (TREE_CODE (t) == VAR_DECL + && (!DECL_EXTERNAL (t) + || !decl_function_context (t))) lto_register_var_decl_in_symtab (data_in, t); - else if (TREE_CODE (t) == FUNCTION_DECL && !DECL_BUILT_IN (t)) + else if (TREE_CODE (t) == FUNCTION_DECL && !DECL_BUILT_IN (t) + && (!DECL_EXTERNAL (t) + || !decl_function_context (t))) lto_register_function_decl_in_symtab (data_in, t); else if (TYPE_P (t) && !TYPE_CANONICAL (t)) TYPE_CANONICAL (t) = gimple_register_canonical_type (t); works great for C it does not work for C++ at all because in static void bar (void) { extern void foo (int); foo (0); } the function-local extern declaration of 'foo' has a toplevel DECL_CONTEXT. Thus the only way I see to fix this bug is to introduce either a new streaming hook or add an argument to the stream_write_tree that indicates whether the actual tree should be streamed by reference, not affecting its siblings.