From: Nathan Froyd <froydnj@codesourcery.com>
To: gcc-patches@gcc.gnu.org
Cc: richard.guenther@gmail.com
Subject: Re: [PATCH 18/18] make TS_BLOCK a substructure of TS_BASE
Date: Thu, 26 May 2011 18:30:00 -0000 [thread overview]
Message-ID: <20110526173942.GA4621@nightcrawler> (raw)
In-Reply-To: <1299817406-16745-19-git-send-email-froydnj@codesourcery.com>
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;
next prev parent reply other threads:[~2011-05-26 17:40 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-11 4:23 [4.7 PATCH 00/18] slim down a number of tree nodes Nathan Froyd
2011-03-11 4:23 ` [PATCH 05/18] remove TREE_CHAIN from CONSTRUCTOR nodes Nathan Froyd
2011-03-11 13:05 ` Richard Guenther
2011-03-11 4:23 ` [PATCH 04/18] remove TREE_CHAIN from SSA_NAME nodes Nathan Froyd
2011-03-11 13:06 ` Richard Guenther
2011-03-11 4:24 ` [PATCH 06/18] define CASE_CHAIN accessor for CASE_LABEL_EXPR Nathan Froyd
2011-03-11 13:07 ` Richard Guenther
2011-03-11 4:24 ` [PATCH 08/18] convert cp *FOR_STMTs to use private scope fields Nathan Froyd
2011-03-11 4:24 ` [PATCH 10/18] convert cp SWITCH_STMTs " Nathan Froyd
2011-03-11 4:24 ` [PATCH 15/18] move REAL_IDENTIFIER_TYPE_VALUE to be a field of lang_identifier Nathan Froyd
2011-03-11 13:40 ` Jason Merrill
2011-03-11 14:04 ` Nathan Froyd
2011-03-11 14:20 ` Nathan Froyd
2011-03-11 15:04 ` Jason Merrill
2011-03-11 16:23 ` Nathan Froyd
2011-03-11 17:17 ` Jason Merrill
2011-03-11 14:41 ` Joseph S. Myers
2011-03-11 4:24 ` [PATCH 01/18] add typed_tree structure Nathan Froyd
2011-03-11 13:05 ` Richard Guenther
2011-03-11 15:21 ` Michael Matz
2011-03-11 4:24 ` [PATCH 13/18] move TS_EXP to be a substructure of TS_TYPED Nathan Froyd
2011-05-11 0:34 ` Nathan Froyd
2011-05-17 17:51 ` [PING][PATCH " Nathan Froyd
2011-05-23 14:58 ` Nathan Froyd
2011-05-23 15:34 ` Richard Guenther
2011-05-24 18:52 ` Nathan Froyd
2011-05-25 9:59 ` Richard Guenther
2011-03-11 4:24 ` [PATCH 07/18] generalize build_case_label to the rest of the compiler Nathan Froyd
2011-03-11 13:01 ` Joseph S. Myers
2011-03-11 13:10 ` Richard Guenther
2011-03-11 14:56 ` Tom Tromey
2011-03-11 4:24 ` [PATCH 03/18] remove TREE_CHAIN from *_CST nodes Nathan Froyd
2011-03-11 13:05 ` Richard Guenther
2011-03-11 4:24 ` [PATCH 16/18] make TS_IDENTIFIER be a substructure of TS_BASE Nathan Froyd
2011-03-11 13:12 ` Richard Guenther
2011-03-11 17:21 ` Nathan Froyd
2011-03-11 4:24 ` [PATCH 14/18] move TS_STATEMENT_LIST to be a substructure of TS_TYPED Nathan Froyd
2011-03-11 6:01 ` Jason Merrill
2011-03-11 12:23 ` Nathan Froyd
2011-03-11 4:30 ` [PATCH 09/18] convert cp IF_STMTs to use private scope fields Nathan Froyd
2011-03-11 4:30 ` [PATCH 11/18] mark EXPR_PACK_EXPANSION as typed only Nathan Froyd
2011-03-11 4:31 ` [PATCH 17/18] introduce block_chainon and use BLOCK_CHAIN more Nathan Froyd
2011-03-11 13:15 ` Richard Guenther
2011-03-11 13:19 ` Nathan Froyd
2011-03-11 15:14 ` Tom Tromey
2011-03-12 12:23 ` Eric Botcazou
2011-03-11 4:31 ` [PATCH 18/18] make TS_BLOCK a substructure of TS_BASE Nathan Froyd
2011-05-26 18:30 ` Nathan Froyd [this message]
2011-03-11 4:31 ` [PATCH 02/18] enforce TREE_CHAIN and TREE_TYPE accesses Nathan Froyd
2011-03-11 8:12 ` Mike Stump
2011-03-11 13:21 ` Richard Guenther
2011-03-11 15:24 ` Tom Tromey
2011-03-12 12:13 ` Eric Botcazou
2011-03-21 13:50 ` Nathan Froyd
2011-03-21 17:50 ` Eric Botcazou
2011-04-13 2:43 ` Nathan Froyd
2011-04-13 2:57 ` Diego Novillo
2011-04-13 4:02 ` Ian Lance Taylor
2011-03-11 4:50 ` [PATCH 12/18] make CASE_LABEL_EXPR not abuse TREE_CHAIN Nathan Froyd
2011-03-11 13:19 ` Richard Guenther
2011-05-10 20:08 ` Nathan Froyd
2011-05-10 20:19 ` Diego Novillo
2011-05-11 9:21 ` Richard Guenther
2011-05-11 19:22 ` H.J. Lu
2011-03-11 8:18 ` [4.7 PATCH 00/18] slim down a number of tree nodes Mike Stump
2011-03-11 16:00 ` Nathan Froyd
2011-03-11 13:25 ` Richard Guenther
2011-03-11 13:42 ` Nathan Froyd
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110526173942.GA4621@nightcrawler \
--to=froydnj@codesourcery.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=richard.guenther@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).