From patchwork Fri Dec 16 14:06:50 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 131827 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 200C71007D7 for ; Sat, 17 Dec 2011 01:07:10 +1100 (EST) Received: (qmail 22506 invoked by alias); 16 Dec 2011 14:07:07 -0000 Received: (qmail 22491 invoked by uid 22791); 16 Dec 2011 14:07:05 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 16 Dec 2011 14:06:52 +0000 Received: from relay1.suse.de (nat.nue.novell.com [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id AAFA6890B6 for ; Fri, 16 Dec 2011 15:06:50 +0100 (CET) Date: Fri, 16 Dec 2011 15:06:50 +0100 (CET) From: Richard Guenther To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR51572 Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 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 This fixes PR51572 - as with LTO we do not call debug_hooks->type_decl for each global TYPE_DECL we run into the issue that if those are emitted lazily they always end up in the limbo DIE list but are later not allowed there (we ICE processing the limbo list). The fix is to not put those on the limbo list in the first place if its context DIE will be a comp-unit-die which is similar enough to the existing handling of NAMESPACE_DECL contexts. Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. Jason approved this on IRC so I will commit it once testing suceeds. [not changing the similar occurance a few lines below - I wasn't able to create a testcase with a quick try, so I'll wait for one to pop up in the wild] Thanks, Richard. 2011-12-16 Richard Guenther PR lto/51572 * dwarf2out.c (gen_type_die_with_usage): Use the context of the TYPE_DECL as well if it is file-scope. * gcc.dg/lto/pr51572-1_0.c: New testcase. Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c (revision 182398) +++ gcc/dwarf2out.c (working copy) @@ -18842,8 +18849,9 @@ gen_type_die_with_usage (tree type, dw_d /* Use the DIE of the containing namespace as the parent DIE of the type description DIE we want to generate. */ - if (DECL_CONTEXT (TYPE_NAME (type)) - && TREE_CODE (DECL_CONTEXT (TYPE_NAME (type))) == NAMESPACE_DECL) + if (DECL_FILE_SCOPE_P (TYPE_NAME (type)) + || (DECL_CONTEXT (TYPE_NAME (type)) + && TREE_CODE (DECL_CONTEXT (TYPE_NAME (type))) == NAMESPACE_DECL)) context_die = get_context_die (DECL_CONTEXT (TYPE_NAME (type))); TREE_ASM_WRITTEN (type) = 1; Index: gcc/testsuite/gcc.dg/lto/pr51572-1_0.c =================================================================== --- gcc/testsuite/gcc.dg/lto/pr51572-1_0.c (revision 0) +++ gcc/testsuite/gcc.dg/lto/pr51572-1_0.c (revision 0) @@ -0,0 +1,9 @@ +/* { dg-lto-do link } */ +/* { dg-lto-options { { -flto -g } } } */ + +typedef int T; +void fn (void) +{ + static T t; +} +int main() {}