From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28188 invoked by alias); 24 Jun 2011 14:44:25 -0000 Received: (qmail 28180 invoked by uid 22791); 24 Jun 2011 14:44:23 -0000 X-SWARE-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 24 Jun 2011 14:44:09 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p5OEi0i1030854 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 24 Jun 2011 10:44:01 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p5OEhx8k022847 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 24 Jun 2011 10:44:00 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (localhost.localdomain [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id p5OEhxYD015044; Fri, 24 Jun 2011 16:43:59 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id p5OEhw5U015042; Fri, 24 Jun 2011 16:43:58 +0200 Date: Fri, 24 Jun 2011 14:58:00 -0000 From: Jakub Jelinek To: Jason Merrill , "Joseph S. Myers" Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Use TYPE_NEXT_VARIANT instead of TREE_CHAIN as chain_next for types during GC (PR c++/46400) Message-ID: <20110624144358.GX16443@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-06/txt/msg01881.txt.bz2 Hi! On the huge testcase in the PR we ICE, because GC needs too deep recursion. I've noticed that part of the problem is deep recursion through TYPE_NEXT_VARIANT pointers. As TREE_CHAIN on types is TYPE_STUB_DECL, therefore should point to a different kind of tree and thus isn't really a pointer through which long chain of trees are linked together, I think we should use TYPE_NEXT_VARIANT as such chain instead. In fact, the C FE already uses it, just for INTEGER_TYPEs only. This patch changes both C and C++ FEs to use it for all types. The patch fixes the testcase (while without the patch it needs roughly 35MB of stack, with the patch 5.25MB is enough) and has been bootstrapped/regtested on x86_64-linux and i686-linux. Ok for trunk? 2011-06-24 Jakub Jelinek PR c++/46400 * cp-tree.h (union lang_tree_node): Use TYPE_NEXT_VARIANT instead of TYPE_CHAIN for chain_next for types. * c-decl.c (union lang_tree_node): Use TYPE_NEXT_VARIANT instead of TYPE_CHAIN for chain_next for types. --- gcc/cp/cp-tree.h.jj 2011-06-21 16:45:52.000000000 +0200 +++ gcc/cp/cp-tree.h 2011-06-24 12:07:42.000000000 +0200 @@ -729,7 +729,7 @@ enum cp_tree_node_structure_enum { /* The resulting tree type. */ union GTY((desc ("cp_tree_node_structure (&%h)"), - chain_next ("CODE_CONTAINS_STRUCT (TREE_CODE (&%h.generic), TS_COMMON) ? ((union lang_tree_node *) TREE_CHAIN (&%h.generic)) : NULL"))) lang_tree_node { + chain_next ("CODE_CONTAINS_STRUCT (TREE_CODE (&%h.generic), TS_TYPE_COMMON) ? ((union lang_tree_node *) TYPE_NEXT_VARIANT (&%h.generic)) : CODE_CONTAINS_STRUCT (TREE_CODE (&%h.generic), TS_COMMON) ? ((union lang_tree_node *) TREE_CHAIN (&%h.generic)) : NULL"))) lang_tree_node { union tree_node GTY ((tag ("TS_CP_GENERIC"), desc ("tree_node_structure (&%h)"))) generic; struct template_parm_index_s GTY ((tag ("TS_CP_TPI"))) tpi; --- gcc/c-decl.c.jj 2011-06-17 11:02:19.000000000 +0200 +++ gcc/c-decl.c 2011-06-24 12:13:35.000000000 +0200 @@ -238,7 +238,7 @@ extern char C_SIZEOF_STRUCT_LANG_IDENTIF /* The resulting tree type. */ union GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"), - chain_next ("TREE_CODE (&%h.generic) == INTEGER_TYPE ? (union lang_tree_node *) TYPE_NEXT_VARIANT (&%h.generic) : CODE_CONTAINS_STRUCT (TREE_CODE (&%h.generic), TS_COMMON) ? ((union lang_tree_node *) TREE_CHAIN (&%h.generic)) : NULL"))) lang_tree_node + chain_next ("CODE_CONTAINS_STRUCT (TREE_CODE (&%h.generic), TS_TYPE_COMMON) ? (union lang_tree_node *) TYPE_NEXT_VARIANT (&%h.generic) : CODE_CONTAINS_STRUCT (TREE_CODE (&%h.generic), TS_COMMON) ? ((union lang_tree_node *) TREE_CHAIN (&%h.generic)) : NULL"))) lang_tree_node { union tree_node GTY ((tag ("0"), desc ("tree_node_structure (&%h)"))) Jakub