Paolo Bonzini - [PATCH 4/5]: Use pointer_map in tree-nested (original) (raw)

This is the mail archive of the gcc-patches@gcc.gnu.orgmailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Here, the data structure was uselessly allocated in GGC space (in fact it was ggc_free'd explicitly). For simplicity I moved it to malloc space, even though a pool could also be a good idea. I also moved the bitmap that were allocated by tree-nested into their own obstack so that all of them can be easily cleared in a single step.Bootstrapped C/C++/Ada/Java (Fortran is broken) on i686-pc-linux-gnu, ok for mainline?Paolo

2006-02-06 Paolo Bonzini bonzini@gnu.org

* Makefile.in (tree-nested.o): Add pointer-set.h dependency.
* tree-nested.c: Include pointer-set.h.
(var_map_elt, var_map_eq, var_map_hash): Delete.
(struct nesting_info): Remove GTY marker.  Change the two htab_t's
to pointer_map_t's.
(nesting_info_bitmap_obstack): New.
(lookup_field_for_decl): Adjust for pointer_map API.
(lookup_tramp_for_decl): Adjust for pointer_map API.
(get_nonlocal_debug_decl): Adjust for pointer_map API.
(get_local_debug_decl): Adjust for pointer_map API.
(convert_nl_goto_reference): Adjust for pointer_map API.
(convert_nl_goto_receiver): Adjust for pointer_map API.
(create_nesting_tree): Create outside GGC space.  Create bitmap on
the new obstack.  Create field_map and var_map as pointer_maps.
(free_nesting_tree): Adjust for changes to create_nesting_tree.
(root): Delete.	
(lower_nested_functions): Move root here, no need to NULL it.
Initialize and release the obstack.

Index: Makefile.in

--- Makefile.in (revision 121601) +++ Makefile.in (working copy) @@ -2078,7 +2078,7 @@ tree-ssa-sink.o : tree-ssa-sink.c $(TREE tree-nested.o: tree-nested.c (CONFIGH)(CONFIG_H) (CONFIGH)(SYSTEM_H) (TMH)(TM_H) (TMH)(TREE_H)
(RTLH)(RTL_H) (RTLH)(TM_P_H) (FUNCTIONH)(FUNCTION_H) (FUNCTIONH)(TREE_DUMP_H) $(TREE_INLINE_H)
tree-iterator.h (TREEGIMPLEH)(TREE_GIMPLE_H) (TREEGIMPLEH)(CGRAPH_H) $(EXPR_H) langhooks.h
- (GGCH)gt−tree−nested.hcoretypes.h(GGC_H) gt-tree-nested.h coretypes.h (GGCH)gttreenested.hcoretypes.h(TREE_FLOW_H) + (GGCH)gt−tree−nested.hcoretypes.h(GGC_H) gt-tree-nested.h coretypes.h (GGCH)gttreenested.hcoretypes.h(TREE_FLOW_H) pointer-set.h tree-if-conv.o: tree-if-conv.c (CONFIGH)(CONFIG_H) (CONFIGH)(SYSTEM_H) coretypes.h $(TM_H)
(TREEH)(TREE_H) (TREEH)(FLAGS_H) (TIMEVARH)(TIMEVAR_H) (TIMEVARH)(BASIC_BLOCK_H) $(TREE_FLOW_H)
(CFGLOOPH)(CFGLOOP_H) (CFGLOOPH)(RTL_H) (CCOMMONH)tree−chrec.h(C_COMMON_H) tree-chrec.h (CCOMMONH)treechrec.h(TREE_DATA_REF_H)
Index: tree-nested.c

--- tree-nested.c (revision 121601) +++ tree-nested.c (working copy) @@ -34,6 +34,7 @@ #include "cgraph.h" #include "expr.h" #include "langhooks.h" +#include "pointer-set.h" #include "ggc.h" @@ -77,20 +78,14 @@ been written as independent functions without change. */ -struct var_map_elt GTY(()) -{ - tree old; - tree new; -};

-struct nesting_info GTY ((chain_next ("%h.next"))) +struct nesting_info { struct nesting_info *outer; struct nesting_info *inner; struct nesting_info *next;
- htab_t GTY ((param_is (struct var_map_elt))) field_map; - htab_t GTY ((param_is (struct var_map_elt))) var_map; + struct pointer_map_t *field_map; + struct pointer_map_t var_map; bitmap suppress_expansion; tree context; @@ -108,22 +103,9 @@ struct nesting_info GTY ((chain_next ("% }; -/ Hashing and equality functions for nesting_info->var_map. / +/ Obstack used for the bitmaps in the struct above. */ +static struct bitmap_obstack nesting_info_bitmap_obstack; -static hashval_t -var_map_hash (const void *x) -{ - const struct var_map_elt *a = (const struct var_map_elt *) x; - return htab_hash_pointer (a->old); -}

-static int -var_map_eq (const void *x, const void *y) -{ - const struct var_map_elt *a = (const struct var_map_elt *) x; - const struct var_map_elt *b = (const struct var_map_elt ) y; - return a->old == b->old; -} / We're working in so many different function contexts simultaneously, that create_tmp_var is dangerous. Prevent mishap. */ @@ -268,22 +250,18 @@ static tree lookup_field_for_decl (struct nesting_info *info, tree decl, enum insert_option insert) { - struct var_map_elt *elt, dummy; void **slot; - tree field; - dummy.old = decl; - slot = htab_find_slot (info->field_map, &dummy, insert); - if (!slot) + if (insert == NO_INSERT) { - gcc_assert (insert != INSERT); - return NULL; + slot = pointer_map_contains (info->field_map, decl); + return slot ? *slot : NULL; } - elt = (struct var_map_elt *) *slot; - if (!elt && insert == INSERT) + slot = pointer_map_insert (info->field_map, decl); + if (!*slot) { - field = make_node (FIELD_DECL); + tree field = make_node (FIELD_DECL); DECL_NAME (field) = DECL_NAME (decl); if (use_pointer_in_frame (decl)) @@ -304,19 +282,13 @@ lookup_field_for_decl (struct nesting_in } insert_field_into_struct (get_frame_type (info), field);

/* Build or return the variable that holds the static chain within @@ -469,39 +441,29 @@ static tree lookup_tramp_for_decl (struct nesting_info *info, tree decl, enum insert_option insert) { - struct var_map_elt *elt, dummy; void **slot; - tree field; - dummy.old = decl; - slot = htab_find_slot (info->var_map, &dummy, insert); - if (!slot) + if (insert == NO_INSERT) { - gcc_assert (insert != INSERT); - return NULL; + slot = pointer_map_contains (info->var_map, decl); + return slot ? *slot : NULL; } - elt = (struct var_map_elt *) *slot; - if (!elt && insert == INSERT) + slot = pointer_map_insert (info->var_map, decl); + if (!*slot) { - field = make_node (FIELD_DECL); + tree field = make_node (FIELD_DECL); DECL_NAME (field) = DECL_NAME (decl); TREE_TYPE (field) = get_trampoline_type (); TREE_ADDRESSABLE (field) = 1; insert_field_into_struct (get_frame_type (info), field);

/* Build or return the field within the non-local frame state that holds @@ -767,10 +729,10 @@ check_for_nested_with_variably_modified static struct nesting_info * create_nesting_tree (struct cgraph_node *cgn) { - struct nesting_info *info = GGC_CNEW (struct nesting_info); - info->field_map = htab_create_ggc (7, var_map_hash, var_map_eq, ggc_free); - info->var_map = htab_create_ggc (7, var_map_hash, var_map_eq, ggc_free); - info->suppress_expansion = BITMAP_GGC_ALLOC (); + struct nesting_info *info = XCNEW (struct nesting_info); + info->field_map = pointer_map_create (); + info->var_map = pointer_map_create (); + info->suppress_expansion = BITMAP_ALLOC (&nesting_info_bitmap_obstack); info->context = cgn->decl; for (cgn = cgn->nested; cgn ; cgn = cgn->next_nested) @@ -865,18 +827,15 @@ get_frame_field (struct nesting_info *in static tree get_nonlocal_debug_decl (struct nesting_info *info, tree decl) { - struct var_map_elt *elt, dummy; tree target_context; struct nesting_info *i; tree x, field, new_decl; void **slot; - dummy.old = decl; - slot = htab_find_slot (info->var_map, &dummy, INSERT); - elt = *slot; + slot = pointer_map_insert (info->var_map, decl); - if (elt) - return elt->new; + if (*slot) + return *slot; target_context = decl_function_context (decl); @@ -920,11 +879,7 @@ get_nonlocal_debug_decl (struct nesting_ SET_DECL_VALUE_EXPR (new_decl, x); DECL_HAS_VALUE_EXPR_P (new_decl) = 1; - elt = ggc_alloc (sizeof (*elt)); - elt->old = decl; - elt->new = new_decl; - *slot = elt;

@@ -1198,16 +1153,12 @@ convert_nonlocal_omp_clauses (tree *pcla static tree get_local_debug_decl (struct nesting_info *info, tree decl, tree field) { - struct var_map_elt *elt, dummy; tree x, new_decl; void **slot; - dummy.old = decl; - slot = htab_find_slot (info->var_map, &dummy, INSERT); - elt = *slot;

/* Make sure frame_decl gets created. */ (void) get_frame_type (info); @@ -1227,11 +1178,7 @@ get_local_debug_decl (struct nesting_inf SET_DECL_VALUE_EXPR (new_decl, x); DECL_HAS_VALUE_EXPR_P (new_decl) = 1;

@@ -1491,7 +1438,6 @@ convert_nl_goto_reference (tree *tp, int struct walk_stmt_info *wi = (struct walk_stmt_info *) data; struct nesting_info *info = wi->info, *i; tree t = *tp, label, new_label, target_context, x, arg, field; - struct var_map_elt *elt, dummy; void **slot; *walk_subtrees = 0; @@ -1514,21 +1460,15 @@ convert_nl_goto_reference (tree *tp, int (hairy target-specific) non-local goto receiver code to be generated when we expand rtl. Enter this association into var_map so that we can insert the new label into the IL during a second pass. */ - dummy.old = label; - slot = htab_find_slot (i->var_map, &dummy, INSERT); - elt = (struct var_map_elt *) *slot; - if (elt == NULL) + slot = pointer_map_insert (i->var_map, label); + if (*slot == NULL) { new_label = create_artificial_label (); DECL_NONLOCAL (new_label) = 1;

/* Main entry point for this pass. Process FNDECL and all of its nested subroutines and turn them into something less tightly bound. */

@@ -1970,12 +1909,14 @@ void lower_nested_functions (tree fndecl) { struct cgraph_node *cgn;

#include "gt-tree-nested.h"


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]