From patchwork Thu May 26 17:39:45 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Froyd X-Patchwork-Id: 97601 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 83636B6F89 for ; Fri, 27 May 2011 03:40:09 +1000 (EST) Received: (qmail 15905 invoked by alias); 26 May 2011 17:40:06 -0000 Received: (qmail 15895 invoked by uid 22791); 26 May 2011 17:40:05 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 26 May 2011 17:39:50 +0000 Received: (qmail 22055 invoked from network); 26 May 2011 17:39:48 -0000 Received: from unknown (HELO codesourcery.com) (froydnj@127.0.0.2) by mail.codesourcery.com with ESMTPA; 26 May 2011 17:39:48 -0000 Date: Thu, 26 May 2011 13:39:45 -0400 From: Nathan Froyd To: gcc-patches@gcc.gnu.org Cc: richard.guenther@gmail.com Subject: Re: [PATCH 18/18] make TS_BLOCK a substructure of TS_BASE Message-ID: <20110526173942.GA4621@nightcrawler> References: <1299817406-16745-1-git-send-email-froydnj@codesourcery.com> <1299817406-16745-19-git-send-email-froydnj@codesourcery.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1299817406-16745-19-git-send-email-froydnj@codesourcery.com> User-Agent: Mutt/1.5.20 (2009-06-14) X-IsSubscribed: yes 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 On Thu, Mar 10, 2011 at 11:23:26PM -0500, Nathan Froyd wrote: > Now that we've encapsulated all uses of BLOCK_CHAINON properly, we can > make BLOCKs inherit from tree_base and redirect BLOCK_CHAINON to use a > tree_block-private field instead of tree_common's chain. Doing so saves > the never-used TREE_TYPE field. This patch was approved: http://gcc.gnu.org/ml/gcc-patches/2011-03/msg00564.html http://gcc.gnu.org/ml/gcc-patches/2011-05/msg01844.html However, during retesting, I hit problems in find_decls_types_r; the following bit of code doesn't work if your trees don't have TREE_TYPE: if (TREE_CODE (t) != IDENTIFIER_NODE) fld_worklist_push (TREE_TYPE (t), fld); This didn't show up when I was developing the patch, since the adjustments to IDENTIFIER_NODE: http://gcc.gnu.org/ml/gcc-patches/2011-03/msg00561.html had done: @@ -4795,7 +4791,8 @@ find_decls_types_r (tree *tp, int *ws, void *data) fld_worklist_push (BLOCK_ABSTRACT_ORIGIN (t), fld); } - fld_worklist_push (TREE_TYPE (t), fld); + if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_TYPED)) + fld_worklist_push (TREE_TYPE (t), fld); return NULL_TREE; } And the later BLOCK-adjusting made use of that bit. Given that removing TREE_TYPE from IDENTIFIER_NODE required more invasive surgery than I'm qualified to do at this point, that bit (and several others) got dropped, leading to our present situation. Since Richi approved the IDENTIFIER_NODE changes, I feel justified in committing the slightly tweaked patch below. The relevant bit that wasn't in the initial mail is: @@ -4892,7 +4892,8 @@ find_decls_types_r (tree *tp, int *ws, void *data) fld_worklist_push (BLOCK_ABSTRACT_ORIGIN (t), fld); } - if (TREE_CODE (t) != IDENTIFIER_NODE) + if (TREE_CODE (t) != IDENTIFIER_NODE + && CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_TYPED)) fld_worklist_push (TREE_TYPE (t), fld); return NULL_TREE; If people feel that checking TREE_CODE for BLOCK or just 'return'ing from the BLOCK block just above would be more appropriate, I can commit that as a followup patch. Tested on x86_64-unknown-linux-gnu. Committed as r174300. -Nathan gcc/ * tree.c (initialize_tree_contains_struct): Mark TS_BLOCK as TS_BASE instead of TS_COMMON. * tree.h (struct tree_block): Inherit from tree_base, not tree_common. Add chain field. (BLOCK_CHAIN): Use new chain field. gcc/c-family/ * c-common.c (warning_candidate_p): Check for BLOCKs. gcc/java/ * decl.c (poplevel): Don't access TREE_TYPE of BLOCKs. * expr.c (build_jni_stub): Likewise. diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 2d4e492..fa7ebc5 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -2367,6 +2367,9 @@ warning_candidate_p (tree x) if (DECL_P (x) && DECL_ARTIFICIAL (x)) return 0; + if (TREE_CODE (x) == BLOCK) + return 0; + /* VOID_TYPE_P (TREE_TYPE (x)) is workaround for cp/tree.c (lvalue_p) crash on TRY/CATCH. */ if (TREE_TYPE (x) == NULL_TREE || VOID_TYPE_P (TREE_TYPE (x))) diff --git a/gcc/java/decl.c b/gcc/java/decl.c index 47b4ebe..e958136 100644 --- a/gcc/java/decl.c +++ b/gcc/java/decl.c @@ -1425,10 +1425,7 @@ poplevel (int keep, int reverse, int functionbody) block = 0; if (keep || functionbody) - { - block = make_node (BLOCK); - TREE_TYPE (block) = void_type_node; - } + block = make_node (BLOCK); if (current_binding_level->exception_range) expand_end_java_handler (current_binding_level->exception_range); @@ -1456,7 +1453,7 @@ poplevel (int keep, int reverse, int functionbody) } *var = NULL; - bind = build3 (BIND_EXPR, TREE_TYPE (block), BLOCK_VARS (block), + bind = build3 (BIND_EXPR, void_type_node, BLOCK_VARS (block), BLOCK_EXPR_BODY (block), block); BIND_EXPR_BODY (bind) = current_binding_level->stmts; diff --git a/gcc/java/expr.c b/gcc/java/expr.c index 3be1cff..b9293e0 100644 --- a/gcc/java/expr.c +++ b/gcc/java/expr.c @@ -2649,7 +2649,6 @@ build_jni_stub (tree method) method_args = DECL_ARGUMENTS (method); block = build_block (env_var, NULL_TREE, method_args, NULL_TREE); TREE_SIDE_EFFECTS (block) = 1; - TREE_TYPE (block) = TREE_TYPE (TREE_TYPE (method)); /* Compute the local `env' by calling _Jv_GetJNIEnvNewFrame. */ body = build2 (MODIFY_EXPR, ptr_type_node, env_var, diff --git a/gcc/tree.c b/gcc/tree.c index 1dfad04..d5b5dac 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -368,6 +368,7 @@ initialize_tree_contains_struct (void) switch (ts_code) { case TS_TYPED: + case TS_BLOCK: MARK_TS_BASE (code); break; @@ -389,7 +390,6 @@ initialize_tree_contains_struct (void) case TS_TYPE_COMMON: case TS_LIST: case TS_VEC: - case TS_BLOCK: case TS_BINFO: case TS_STATEMENT_LIST: case TS_OMP_CLAUSE: @@ -4892,7 +4892,8 @@ find_decls_types_r (tree *tp, int *ws, void *data) fld_worklist_push (BLOCK_ABSTRACT_ORIGIN (t), fld); } - if (TREE_CODE (t) != IDENTIFIER_NODE) + if (TREE_CODE (t) != IDENTIFIER_NODE + && CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_TYPED)) fld_worklist_push (TREE_TYPE (t), fld); return NULL_TREE; diff --git a/gcc/tree.h b/gcc/tree.h index 142237f..aefaea8 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -2051,9 +2051,7 @@ struct GTY(()) tree_omp_clause { VEC_index (tree, BLOCK_NONLOCALIZED_VARS (NODE), N) #define BLOCK_SUBBLOCKS(NODE) (BLOCK_CHECK (NODE)->block.subblocks) #define BLOCK_SUPERCONTEXT(NODE) (BLOCK_CHECK (NODE)->block.supercontext) -/* Note: when changing this, make sure to find the places - that use chainon or nreverse. */ -#define BLOCK_CHAIN(NODE) TREE_CHAIN (BLOCK_CHECK (NODE)) +#define BLOCK_CHAIN(NODE) (BLOCK_CHECK (NODE)->block.chain) #define BLOCK_ABSTRACT_ORIGIN(NODE) (BLOCK_CHECK (NODE)->block.abstract_origin) #define BLOCK_ABSTRACT(NODE) (BLOCK_CHECK (NODE)->block.abstract_flag) @@ -2094,7 +2092,8 @@ struct GTY(()) tree_omp_clause { #define BLOCK_SOURCE_LOCATION(NODE) (BLOCK_CHECK (NODE)->block.locus) struct GTY(()) tree_block { - struct tree_common common; + struct tree_base base; + tree chain; unsigned abstract_flag : 1; unsigned block_num : 31;