From 7d6e252187acf272b527bb1e2203836e2cc73a30 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Wed, 27 Apr 2011 14:16:49 +0000 Subject: [PATCH] Makefile.in (tree-ssa-structalias.o): Remove gt-tree-ssa-structalias.h dependency. 2011-04-27 Richard Guenther * Makefile.in (tree-ssa-structalias.o): Remove gt-tree-ssa-structalias.h dependency. (GTFILES): Remove tree-ssa-structalias.c. * tree.c (allocate_decl_uid): New function. (make_node_stat): Use it. (copy_node_stat): Likewise. * tree.h (allocate_decl_uid): Declare. * tree-ssa-alias.h (delete_alias_heapvars): Remove. * tree-ssa.c (delete_tree_ssa): Do not call delete_alias_heapvars. * tree-flow.h (struct var_ann_d): Remove is_heapvar flag. * tree-ssa-live.c (remove_unused_locals): Do not check is_heapvar flag. * tree-ssa-structalias.c (heapvar_for_stmt): Remove. (struct heapvar_map): Likewise. (heapvar_map_eq, heapvar_map_hash, heapvar_lookup, heapvar_insert): Likewise. (make_heapvar_for): Rename to ... (make_heapvar): ... this. Simplify. (fake_var_decl_obstack): New global var. (build_fake_var_decl): New function. (make_constraint_from_heapvar): Adjust. (handle_lhs_call): Likewise. (create_function_info_for): Likewise. (intra_create_variable_infos): Likewise. (init_alias_vars): Allocate fake_var_decl_obstack. (init_alias_heapvars, delete_alias_heapvars): Remove. (compute_points_to_sets): Do not call init_alias_heapvars. (ipa_pta_execute): Likewise. (delete_points_to_sets): Free fake_var_decl_obstack. * gcc.dg/tree-ssa/pr23382.c: Remove. From-SVN: r173030 --- gcc/ChangeLog | 32 +++++ gcc/Makefile.in | 3 +- gcc/testsuite/ChangeLog | 4 + gcc/testsuite/gcc.dg/tree-ssa/pr23382.c | 17 --- gcc/tree-flow.h | 4 - gcc/tree-ssa-alias.h | 1 - gcc/tree-ssa-live.c | 3 +- gcc/tree-ssa-structalias.c | 153 ++++++------------------ gcc/tree-ssa.c | 2 - gcc/tree.c | 12 +- gcc/tree.h | 3 + 11 files changed, 85 insertions(+), 149 deletions(-) delete mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr23382.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f2b75b07e91..885529ec7c5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,35 @@ +2011-04-27 Richard Guenther + + * Makefile.in (tree-ssa-structalias.o): Remove + gt-tree-ssa-structalias.h dependency. + (GTFILES): Remove tree-ssa-structalias.c. + * tree.c (allocate_decl_uid): New function. + (make_node_stat): Use it. + (copy_node_stat): Likewise. + * tree.h (allocate_decl_uid): Declare. + * tree-ssa-alias.h (delete_alias_heapvars): Remove. + * tree-ssa.c (delete_tree_ssa): Do not call delete_alias_heapvars. + * tree-flow.h (struct var_ann_d): Remove is_heapvar flag. + * tree-ssa-live.c (remove_unused_locals): Do not check is_heapvar + flag. + * tree-ssa-structalias.c (heapvar_for_stmt): Remove. + (struct heapvar_map): Likewise. + (heapvar_map_eq, heapvar_map_hash, heapvar_lookup, + heapvar_insert): Likewise. + (make_heapvar_for): Rename to ... + (make_heapvar): ... this. Simplify. + (fake_var_decl_obstack): New global var. + (build_fake_var_decl): New function. + (make_constraint_from_heapvar): Adjust. + (handle_lhs_call): Likewise. + (create_function_info_for): Likewise. + (intra_create_variable_infos): Likewise. + (init_alias_vars): Allocate fake_var_decl_obstack. + (init_alias_heapvars, delete_alias_heapvars): Remove. + (compute_points_to_sets): Do not call init_alias_heapvars. + (ipa_pta_execute): Likewise. + (delete_points_to_sets): Free fake_var_decl_obstack. + 2011-04-27 Ulrich Weigand * config/spu/divmovti4.c (union qword_UTItype): New data type. diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 9b85ad0564c..618046c0b1a 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -2381,7 +2381,7 @@ tree-ssa-structalias.o: tree-ssa-structalias.c \ $(DIAGNOSTIC_H) $(TREE_H) $(TREE_FLOW_H) $(TREE_INLINE_H) \ $(GIMPLE_H) $(HASHTAB_H) $(FUNCTION_H) $(CGRAPH_H) \ $(TREE_PASS_H) $(TIMEVAR_H) alloc-pool.h $(SPLAY_TREE_H) $(PARAMS_H) \ - gt-tree-ssa-structalias.h $(CGRAPH_H) $(ALIAS_H) pointer-set.h + $(CGRAPH_H) $(ALIAS_H) pointer-set.h tree-ssa-uninit.o : tree-ssa-uninit.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \ $(TREE_H) $(TM_P_H) $(EXPR_H) output.h $(DIAGNOSTIC_H) \ $(FUNCTION_H) $(TIMEVAR_H) $(TM_H) coretypes.h \ @@ -3776,7 +3776,6 @@ GTFILES = $(CPP_ID_DATA_H) $(srcdir)/input.h $(srcdir)/coretypes.h \ $(srcdir)/targhooks.c $(out_file) $(srcdir)/passes.c $(srcdir)/cgraphunit.c \ $(srcdir)/tree-ssa-propagate.c \ $(srcdir)/tree-phinodes.c \ - $(srcdir)/tree-ssa-structalias.c \ $(srcdir)/lto-symtab.c \ $(srcdir)/tree-ssa-alias.h \ $(srcdir)/ipa-prop.h \ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6fca754f1e5..a745edcac56 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2011-04-27 Richard Guenther + + * gcc.dg/tree-ssa/pr23382.c: Remove. + 2011-04-27 Kaz Kojima PR target/48767 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr23382.c b/gcc/testsuite/gcc.dg/tree-ssa/pr23382.c deleted file mode 100644 index fd74af8d6a1..00000000000 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr23382.c +++ /dev/null @@ -1,17 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-pre-details" } */ -struct a -{ - int length; - int a1[256]; -}; - -void *malloc(__SIZE_TYPE__ size) __attribute__((malloc)); - -int f(void) -{ - struct a *a = malloc(sizeof(struct a)); - return a->length; -} -/* { dg-final { scan-tree-dump-times "Variable: HEAP" 1 "pre"} } */ -/* { dg-final { cleanup-tree-dump "pre" } } */ diff --git a/gcc/tree-flow.h b/gcc/tree-flow.h index 2ac2bbb66f5..adae4630b01 100644 --- a/gcc/tree-flow.h +++ b/gcc/tree-flow.h @@ -172,10 +172,6 @@ struct GTY(()) var_ann_d { states. */ ENUM_BITFIELD (need_phi_state) need_phi_state : 2; - /* True for HEAP artificial variables. These variables represent - the memory area allocated by a call to malloc. */ - unsigned is_heapvar : 1; - /* Used by var_map for the base index of ssa base variables. */ unsigned base_index; diff --git a/gcc/tree-ssa-alias.h b/gcc/tree-ssa-alias.h index 8a9da0e7726..75e4303a7ab 100644 --- a/gcc/tree-ssa-alias.h +++ b/gcc/tree-ssa-alias.h @@ -125,7 +125,6 @@ extern void dump_alias_stats (FILE *); /* In tree-ssa-structalias.c */ extern unsigned int compute_may_aliases (void); -extern void delete_alias_heapvars (void); extern bool pt_solution_empty_p (struct pt_solution *); extern bool pt_solution_includes_global (struct pt_solution *); extern bool pt_solution_includes (struct pt_solution *, const_tree); diff --git a/gcc/tree-ssa-live.c b/gcc/tree-ssa-live.c index 4216b225851..65b3855775a 100644 --- a/gcc/tree-ssa-live.c +++ b/gcc/tree-ssa-live.c @@ -820,8 +820,7 @@ remove_unused_locals (void) if (!is_global_var (t) && TREE_CODE (t) != PARM_DECL && TREE_CODE (t) != RESULT_DECL - && !is_used_p (t) - && !var_ann (t)->is_heapvar) + && !is_used_p (t)) remove_referenced_var (t); remove_unused_scope_block_p (DECL_INITIAL (current_function_decl)); if (dump_file && (dump_flags & TDF_DETAILS)) diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index 70405a16137..1119c387d15 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -197,8 +197,6 @@ keep the set of called functions for indirect calls. And probably more. */ -static GTY ((if_marked ("tree_map_marked_p"), param_is (struct heapvar_map))) -htab_t heapvar_for_stmt; static bool use_field_sensitive = true; static int in_ipa_mode = 0; @@ -333,61 +331,6 @@ enum { nothing_id = 0, anything_id = 1, readonly_id = 2, escaped_id = 3, nonlocal_id = 4, storedanything_id = 5, integer_id = 6 }; -struct GTY(()) heapvar_map { - struct tree_map map; - unsigned HOST_WIDE_INT offset; -}; - -static int -heapvar_map_eq (const void *p1, const void *p2) -{ - const struct heapvar_map *h1 = (const struct heapvar_map *)p1; - const struct heapvar_map *h2 = (const struct heapvar_map *)p2; - return (h1->map.base.from == h2->map.base.from - && h1->offset == h2->offset); -} - -static unsigned int -heapvar_map_hash (struct heapvar_map *h) -{ - return iterative_hash_host_wide_int (h->offset, - htab_hash_pointer (h->map.base.from)); -} - -/* Lookup a heap var for FROM, and return it if we find one. */ - -static tree -heapvar_lookup (tree from, unsigned HOST_WIDE_INT offset) -{ - struct heapvar_map *h, in; - in.map.base.from = from; - in.offset = offset; - h = (struct heapvar_map *) htab_find_with_hash (heapvar_for_stmt, &in, - heapvar_map_hash (&in)); - if (h) - return h->map.to; - return NULL_TREE; -} - -/* Insert a mapping FROM->TO in the heap var for statement - hashtable. */ - -static void -heapvar_insert (tree from, unsigned HOST_WIDE_INT offset, tree to) -{ - struct heapvar_map *h; - void **loc; - - h = ggc_alloc_heapvar_map (); - h->map.base.from = from; - h->offset = offset; - h->map.hash = heapvar_map_hash (h); - h->map.to = to; - loc = htab_find_slot_with_hash (heapvar_for_stmt, h, h->map.hash, INSERT); - gcc_assert (*loc == NULL); - *(struct heapvar_map **) loc = h; -} - /* Return a new variable info structure consisting for a variable named NAME, and using constraint graph node NODE. Append it to the vector of variable info structures. */ @@ -3664,31 +3607,35 @@ make_transitive_closure_constraints (varinfo_t vi) process_constraint (new_constraint (lhs, rhs)); } +/* Temporary storage for fake var decls. */ +struct obstack fake_var_decl_obstack; + +/* Build a fake VAR_DECL acting as referrer to a DECL_UID. */ + +static tree +build_fake_var_decl (tree type) +{ + tree decl = (tree) XOBNEW (&fake_var_decl_obstack, struct tree_var_decl); + memset (decl, 0, sizeof (struct tree_var_decl)); + TREE_SET_CODE (decl, VAR_DECL); + TREE_TYPE (decl) = type; + DECL_UID (decl) = allocate_decl_uid (); + SET_DECL_PT_UID (decl, -1); + layout_decl (decl, 0); + return decl; +} + /* Create a new artificial heap variable with NAME. Return the created variable. */ static varinfo_t -make_heapvar_for (varinfo_t lhs, const char *name) +make_heapvar (const char *name) { varinfo_t vi; - tree heapvar = heapvar_lookup (lhs->decl, lhs->offset); - - if (heapvar == NULL_TREE) - { - var_ann_t ann; - heapvar = create_tmp_var_raw (ptr_type_node, name); - DECL_EXTERNAL (heapvar) = 1; - - heapvar_insert (lhs->decl, lhs->offset, heapvar); - - ann = get_var_ann (heapvar); - ann->is_heapvar = 1; - } - - /* For global vars we need to add a heapvar to the list of referenced - vars of a different function than it was created for originally. */ - if (cfun && gimple_referenced_vars (cfun)) - add_referenced_var (heapvar); + tree heapvar; + + heapvar = build_fake_var_decl (ptr_type_node); + DECL_EXTERNAL (heapvar) = 1; vi = new_var_info (heapvar, name); vi->is_artificial_var = true; @@ -3709,7 +3656,7 @@ make_heapvar_for (varinfo_t lhs, const char *name) static varinfo_t make_constraint_from_heapvar (varinfo_t lhs, const char *name) { - varinfo_t vi = make_heapvar_for (lhs, name); + varinfo_t vi = make_heapvar (name); make_constraint_from (lhs, vi->id); return vi; @@ -3907,7 +3854,7 @@ handle_lhs_call (gimple stmt, tree lhs, int flags, VEC(ce_s, heap) *rhsc, varinfo_t vi; struct constraint_expr tmpc; rhsc = NULL; - vi = make_heapvar_for (get_vi_for_tree (lhs), "HEAP"); + vi = make_heapvar ("HEAP"); /* We delay marking allocated storage global until we know if it escapes. */ DECL_EXTERNAL (vi->decl) = 0; @@ -5323,8 +5270,7 @@ create_function_info_for (tree decl, const char *name) free (tempname); /* We need sth that can be pointed to for va_start. */ - decl = create_tmp_var_raw (ptr_type_node, name); - get_var_ann (decl); + decl = build_fake_var_decl (ptr_type_node); argvi = new_var_info (decl, newname); argvi->offset = fi_parm_base + num_args; @@ -5587,23 +5533,13 @@ intra_create_variable_infos (void) { struct constraint_expr lhsc, rhsc; varinfo_t vi; - tree heapvar = heapvar_lookup (t, 0); - if (heapvar == NULL_TREE) - { - var_ann_t ann; - heapvar = create_tmp_var_raw (TREE_TYPE (TREE_TYPE (t)), - "PARM_NOALIAS"); - DECL_EXTERNAL (heapvar) = 1; - heapvar_insert (t, 0, heapvar); - ann = get_var_ann (heapvar); - ann->is_heapvar = 1; - } - if (gimple_referenced_vars (cfun)) - add_referenced_var (heapvar); + tree heapvar = build_fake_var_decl (TREE_TYPE (TREE_TYPE (t))); + DECL_EXTERNAL (heapvar) = 1; + vi = get_varinfo (create_variable_info_for (heapvar, "PARM_NOALIAS")); lhsc.var = get_vi_for_tree (t)->id; lhsc.type = SCALAR; lhsc.offset = 0; - rhsc.var = (vi = get_vi_for_tree (heapvar))->id; + rhsc.var = vi->id; rhsc.type = ADDRESSOF; rhsc.offset = 0; process_constraint (new_constraint (lhsc, rhsc)); @@ -6371,6 +6307,8 @@ init_alias_vars (void) shared_bitmap_table = htab_create (511, shared_bitmap_hash, shared_bitmap_eq, free); init_base_vars (); + + gcc_obstack_init (&fake_var_decl_obstack); } /* Remove the REF and ADDRESS edges from GRAPH, as well as all the @@ -6409,26 +6347,6 @@ remove_preds_and_fake_succs (constraint_graph_t graph) bitmap_obstack_release (&predbitmap_obstack); } -/* Initialize the heapvar for statement mapping. */ - -static void -init_alias_heapvars (void) -{ - if (!heapvar_for_stmt) - heapvar_for_stmt = htab_create_ggc (11, tree_map_hash, heapvar_map_eq, - NULL); -} - -/* Delete the heapvar for statement mapping. */ - -void -delete_alias_heapvars (void) -{ - if (heapvar_for_stmt) - htab_delete (heapvar_for_stmt); - heapvar_for_stmt = NULL; -} - /* Solve the constraint set. */ static void @@ -6500,7 +6418,6 @@ compute_points_to_sets (void) timevar_push (TV_TREE_PTA); init_alias_vars (); - init_alias_heapvars (); intra_create_variable_infos (); @@ -6651,6 +6568,8 @@ delete_points_to_sets (void) VEC_free (varinfo_t, heap, varmap); free_alloc_pool (variable_info_pool); free_alloc_pool (constraint_pool); + + obstack_free (&fake_var_decl_obstack, NULL); } @@ -6776,7 +6695,6 @@ ipa_pta_execute (void) in_ipa_mode = 1; - init_alias_heapvars (); init_alias_vars (); /* Build the constraints. */ @@ -7119,6 +7037,3 @@ struct simple_ipa_opt_pass pass_ipa_pta = TODO_update_ssa /* todo_flags_finish */ } }; - - -#include "gt-tree-ssa-structalias.h" diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index 9ae280a7e32..9bdcdfcb1d2 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -1187,8 +1187,6 @@ delete_tree_ssa (void) if (ssa_operands_active ()) fini_ssa_operands (); - delete_alias_heapvars (); - htab_delete (cfun->gimple_df->default_defs); cfun->gimple_df->default_defs = NULL; pt_solution_reset (&cfun->gimple_df->escaped); diff --git a/gcc/tree.c b/gcc/tree.c index 6f93fb16336..b175221c779 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -814,6 +814,14 @@ record_node_allocation_statistics (enum tree_code code ATTRIBUTE_UNUSED, #endif } +/* Allocate and return a new UID from the DECL_UID namespace. */ + +int +allocate_decl_uid (void) +{ + return next_decl_uid++; +} + /* Return a newly allocated node of code CODE. For decl and type nodes, some other fields are initialized. The rest of the node is initialized to zero. This function cannot be used for TREE_VEC or @@ -857,7 +865,7 @@ make_node_stat (enum tree_code code MEM_STAT_DECL) DECL_UID (t) = --next_debug_decl_uid; else { - DECL_UID (t) = next_decl_uid++; + DECL_UID (t) = allocate_decl_uid (); SET_DECL_PT_UID (t, -1); } if (TREE_CODE (t) == LABEL_DECL) @@ -942,7 +950,7 @@ copy_node_stat (tree node MEM_STAT_DECL) DECL_UID (t) = --next_debug_decl_uid; else { - DECL_UID (t) = next_decl_uid++; + DECL_UID (t) = allocate_decl_uid (); if (DECL_PT_UID_SET_P (node)) SET_DECL_PT_UID (t, DECL_PT_UID (node)); } diff --git a/gcc/tree.h b/gcc/tree.h index 8f25832589f..8baaf7b7fd0 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -4017,6 +4017,9 @@ extern size_t tree_size (const_tree); length. */ extern size_t tree_code_size (enum tree_code); +/* Allocate and return a new UID from the DECL_UID namespace. */ +extern int allocate_decl_uid (void); + /* Lowest level primitive for allocating a node. The TREE_CODE is the only argument. Contents are initialized to zero except for a few of the common fields. */ -- 2.30.2