From patchwork Fri Mar 11 04:23:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Froyd X-Patchwork-Id: 86362 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 F40E4B6FA4 for ; Fri, 11 Mar 2011 15:24:30 +1100 (EST) Received: (qmail 17476 invoked by alias); 11 Mar 2011 04:23:52 -0000 Received: (qmail 17198 invoked by uid 22791); 11 Mar 2011 04:23:49 -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; Fri, 11 Mar 2011 04:23:44 +0000 Received: (qmail 1585 invoked from network); 11 Mar 2011 04:23:42 -0000 Received: from unknown (HELO codesourcery.com) (froydnj@127.0.0.2) by mail.codesourcery.com with ESMTPA; 11 Mar 2011 04:23:42 -0000 From: Nathan Froyd To: gcc-patches@gcc.gnu.org Cc: Nathan Froyd Subject: [PATCH 04/18] remove TREE_CHAIN from SSA_NAME nodes Date: Thu, 10 Mar 2011 23:23:12 -0500 Message-Id: <1299817406-16745-5-git-send-email-froydnj@codesourcery.com> In-Reply-To: <1299817406-16745-1-git-send-email-froydnj@codesourcery.com> References: <1299817406-16745-1-git-send-email-froydnj@codesourcery.com> 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 This conversion is straightforward. The tricky part is converting FREE_SSANAMES into a VEC to eliminate the only use of TREE_CHAIN on SSA_NAMEs. -Nathan gcc/ * tree-flow.h (struct gimple_df): Make free_ssanames a VEC. * tree-ssanames.c (fini_ssanames): VEC_free it. (make_ssa_name_fn): Update for VECness of free_ssanames. (release_ssa_name, release_dead_ssa_names): Likewise. * tree.h (struct tree_ssa_name): Include typed_tree instead of tree_common. * tree.c (initialize_tree_contains_struct): Mark TS_SSA_NAME as TS_TYPED instead of TS_COMMON. diff --git a/gcc/tree-flow.h b/gcc/tree-flow.h index 14c8827..6b48697 100644 --- a/gcc/tree-flow.h +++ b/gcc/tree-flow.h @@ -61,7 +61,7 @@ struct GTY(()) gimple_df { struct pointer_map_t * GTY((skip(""))) decls_to_pointers; /* Free list of SSA_NAMEs. */ - tree free_ssanames; + VEC(tree,gc) *free_ssanames; /* Hashtable holding definition for symbol. If this field is not NULL, it means that the first reference to this variable in the function is a diff --git a/gcc/tree-ssanames.c b/gcc/tree-ssanames.c index c76dba5..06cdbee 100644 --- a/gcc/tree-ssanames.c +++ b/gcc/tree-ssanames.c @@ -96,7 +96,7 @@ void fini_ssanames (void) { VEC_free (tree, gc, SSANAMES (cfun)); - FREE_SSANAMES (cfun) = NULL; + VEC_free (tree, gc, FREE_SSANAMES (cfun)); } /* Dump some simple statistics regarding the re-use of SSA_NAME nodes. */ @@ -124,10 +124,9 @@ make_ssa_name_fn (struct function *fn, tree var, gimple stmt) gcc_assert (DECL_P (var)); /* If our free list has an element, then use it. */ - if (FREE_SSANAMES (fn)) + if (!VEC_empty (tree, FREE_SSANAMES (fn))) { - t = FREE_SSANAMES (fn); - FREE_SSANAMES (fn) = TREE_CHAIN (FREE_SSANAMES (fn)); + t = VEC_pop (tree, FREE_SSANAMES (fn)); #ifdef GATHER_STATISTICS ssa_name_nodes_reused++; #endif @@ -234,9 +233,8 @@ release_ssa_name (tree var) /* Note this SSA_NAME is now in the first list. */ SSA_NAME_IN_FREE_LIST (var) = 1; - /* And finally link it into the free list. */ - TREE_CHAIN (var) = FREE_SSANAMES (cfun); - FREE_SSANAMES (cfun) = var; + /* And finally put it on the free list. */ + VEC_safe_push (tree, gc, FREE_SSANAMES (cfun), var); } } @@ -334,8 +332,8 @@ replace_ssa_name_symbol (tree ssa_name, tree sym) static unsigned int release_dead_ssa_names (void) { - tree t, next; - int n = 0; + tree t; + int n = VEC_length (tree, FREE_SSANAMES (cfun)); referenced_var_iterator rvi; /* Current defs point to various dead SSA names that in turn point to @@ -343,17 +341,7 @@ release_dead_ssa_names (void) FOR_EACH_REFERENCED_VAR (cfun, t, rvi) set_current_def (t, NULL); /* Now release the freelist. */ - for (t = FREE_SSANAMES (cfun); t; t = next) - { - next = TREE_CHAIN (t); - /* Dangling pointers might make GGC to still see dead SSA names, so it is - important to unlink the list and avoid GGC from seeing all subsequent - SSA names. In longer run we want to have all dangling pointers here - removed (since they usually go through dead statements that consume - considerable amounts of memory). */ - TREE_CHAIN (t) = NULL_TREE; - n++; - } + VEC_free (tree, gc, FREE_SSANAMES (cfun)); FREE_SSANAMES (cfun) = NULL; statistics_counter_event (cfun, "SSA names released", n); diff --git a/gcc/tree.c b/gcc/tree.c index 7d73c74..072ff19 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -376,6 +376,7 @@ initialize_tree_contains_struct (void) case TS_VECTOR: case TS_STRING: case TS_COMPLEX: + case TS_SSA_NAME: MARK_TS_TYPED (code); break; @@ -385,7 +386,6 @@ initialize_tree_contains_struct (void) case TS_LIST: case TS_VEC: case TS_EXP: - case TS_SSA_NAME: case TS_BLOCK: case TS_BINFO: case TS_STATEMENT_LIST: diff --git a/gcc/tree.h b/gcc/tree.h index 11c2f83..80888bc 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -1970,7 +1970,7 @@ typedef struct GTY(()) ssa_use_operand_d { #define SSA_NAME_IMM_USE_NODE(NODE) SSA_NAME_CHECK (NODE)->ssa_name.imm_uses struct GTY(()) tree_ssa_name { - struct tree_common common; + struct typed_tree typed; /* _DECL wrapped by this SSA name. */ tree var;