From patchwork Mon Jun 11 14:12:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 164134 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 D7C221007D1 for ; Tue, 12 Jun 2012 00:13:32 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1340028813; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Date: From:To:Subject:Message-ID:MIME-Version:Content-Type: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=rDGCVUabJzyXG3GF8sg/ +4Dx1E8=; b=xUFxWZke78aXTl55IraUW06NlMb+BPKDADe/dHtVcoTc2UbyerM1 xcrgVzIdH9rZ9vEFXTzYhkdbzFcUkYbADwLFYhr3FmLJ6lxA2dU615dwdYQFtPWq x5G8M2mglg1ID4ysIZcLzIAC+t1xFiQd1Zh1yFoVVzDf6mwYqsWUVx4= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Date:From:To:Subject:Message-ID:MIME-Version:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=c3zLnDbmwx7oc4oqABT1VtLqERjMxmFbnXMTjLtpgyOnKm7X565QkcHGheRZo6 khNaL9P9IM8HB+nimvmUeUFwVNKOvybm3CdvXiW5zuyWdTNZQY4/mYvzrbA4gefK 2xvxOjnsjoaYdVDN9DRIqd6cb1lBLCbmkCXklsTmcdZiU=; Received: (qmail 3757 invoked by alias); 11 Jun 2012 14:13:24 -0000 Received: (qmail 3746 invoked by uid 22791); 11 Jun 2012 14:13:22 -0000 X-SWARE-Spam-Status: No, hits=-5.3 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, T_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; Mon, 11 Jun 2012 14:12:58 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 99D7D9312C for ; Mon, 11 Jun 2012 16:12:57 +0200 (CEST) Date: Mon, 11 Jun 2012 16:12:57 +0200 (CEST) From: Richard Guenther To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR53470 Message-ID: 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 PR53470 - I for quite some time wanted to remove that conditional clearing of TYPE_CONTEXT from free_lang_data_in_type but failed to do so because we regress. I've debugged it down to the C frontend having sometimes BLOCK as TYPE_CONTEXT for a type. So, simply replace such BLOCK with the nearest non-BLOCK we can get at. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk. Richard. 2012-06-11 Richard Guenther PR middle-end/53470 * tree.c (free_lang_data_in_type): Do not clear TYPE_CONTEXT but replace it with the first non-BLOCK context. * g++.dg/lto/pr53470_0.C: New testcase. * gcc.dg/lto/pr53470_0.c: Likewise. Index: gcc/tree.c =================================================================== --- gcc/tree.c (revision 188384) +++ gcc/tree.c (working copy) @@ -4575,11 +4575,17 @@ free_lang_data_in_type (tree type) free_lang_data_in_one_sizepos (&TYPE_SIZE (type)); free_lang_data_in_one_sizepos (&TYPE_SIZE_UNIT (type)); - if (debug_info_level < DINFO_LEVEL_TERSE - || (TYPE_CONTEXT (type) - && TREE_CODE (TYPE_CONTEXT (type)) != FUNCTION_DECL - && TREE_CODE (TYPE_CONTEXT (type)) != NAMESPACE_DECL)) - TYPE_CONTEXT (type) = NULL_TREE; + if (TYPE_CONTEXT (type) + && TREE_CODE (TYPE_CONTEXT (type)) == BLOCK) + { + tree ctx = TYPE_CONTEXT (type); + do + { + ctx = BLOCK_SUPERCONTEXT (ctx); + } + while (ctx && TREE_CODE (ctx) == BLOCK); + TYPE_CONTEXT (type) = ctx; + } } Index: gcc/testsuite/g++.dg/lto/pr53470_0.C =================================================================== --- gcc/testsuite/g++.dg/lto/pr53470_0.C (revision 0) +++ gcc/testsuite/g++.dg/lto/pr53470_0.C (revision 0) @@ -0,0 +1,26 @@ +// { dg-lto-do link } +// { dg-lto-options { { -g -flto } } } + +class sp_counted_base; +class shared_count { + sp_counted_base *pi_; +public: + template shared_count(Y) : pi_() {} + ~shared_count() {} +}; +template struct shared_ptr { + T element_type; + template shared_ptr(Y) : pn(0) {} + shared_count pn; +}; +template class ECGetterBase; +template struct ExtensionCord { + struct Holder { + ECGetterBase *getter_; + }; + ExtensionCord() : holder_(new Holder) {} + + shared_ptr holder_; +}; +ExtensionCord a; +int main() {} Index: gcc/testsuite/gcc.dg/lto/pr53470_0.c =================================================================== --- gcc/testsuite/gcc.dg/lto/pr53470_0.c (revision 0) +++ gcc/testsuite/gcc.dg/lto/pr53470_0.c (revision 0) @@ -0,0 +1,9 @@ +/* { dg-lto-do link } */ +/* { dg-lto-options { { -flto } { -flto -g } } } */ + +int main () +{ + { + union A { } v; + } +}