On 09/24/2011 05:29 PM, Eric Botcazou wrote: >> This is an updated version of the patch. I have 2 new patches and an >> updated testcase which I will sent out individually. >> >> Patch set was bootstrapped and reg-tested on x86_64. >> >> Ok for trunk? >> >> Thanks, >> - Tom >> >> 2011-07-30 Tom de Vries <t...@codesourcery.com> >> >> PR middle-end/43513 >> * Makefile.in (tree-ssa-ccp.o): Add $(PARAMS_H) to rule. >> * tree-ssa-ccp.c (params.h): Include. >> (fold_builtin_alloca_for_var): New function. >> (ccp_fold_stmt): Use fold_builtin_alloca_for_var. > > We have detected another fallout on some Ada code: the transformation > replaces > a call to __builtin_alloca with &var, i.e. it introduces an aliased variable, > which invalidates the points-to information of some subsequent call, fooling > DSE into thinking that it can eliminate a live store. > > The brute force approach > > Index: tree-ssa-ccp.c > =================================================================== > --- tree-ssa-ccp.c (revision 179038) > +++ tree-ssa-ccp.c (working copy) > @@ -2014,7 +2014,10 @@ do_ssa_ccp (void) > ccp_initialize (); > ssa_propagate (ccp_visit_stmt, ccp_visit_phi_node); > if (ccp_finalize ()) > - return (TODO_cleanup_cfg | TODO_update_ssa | TODO_remove_unused_locals); > + return (TODO_cleanup_cfg > + | TODO_update_ssa > + | TODO_rebuild_alias > + | TODO_remove_unused_locals); > else > return 0; > } > > works, but we might want to be move clever. Thoughts? >
How about attached (untested) patch implementing a conservative, but runtime-efficient approach? Thanks, - Tom
Index: gcc/tree-ssa-ccp.c =================================================================== --- gcc/tree-ssa-ccp.c (revision 179043) +++ gcc/tree-ssa-ccp.c (working copy) @@ -1729,6 +1729,7 @@ fold_builtin_alloca_for_var (gimple stmt array_type = build_array_type_nelts (elem_type, n_elem); var = create_tmp_var (array_type, NULL); DECL_ALIGN (var) = align; + pt_solution_add_var (&get_ptr_info (lhs)->pt, var); /* Fold alloca to the address of the array. */ return fold_convert (TREE_TYPE (lhs), build_fold_addr_expr (var)); Index: gcc/tree-ssa-alias.h =================================================================== --- gcc/tree-ssa-alias.h (revision 179043) +++ gcc/tree-ssa-alias.h (working copy) @@ -125,6 +125,7 @@ extern void dump_alias_stats (FILE *); /* In tree-ssa-structalias.c */ extern unsigned int compute_may_aliases (void); +extern void pt_solution_add_var (struct pt_solution *, tree); 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); Index: gcc/tree-ssa-structalias.c =================================================================== --- gcc/tree-ssa-structalias.c (revision 179043) +++ gcc/tree-ssa-structalias.c (working copy) @@ -5952,6 +5952,14 @@ pt_solution_ior_into (struct pt_solution bitmap_ior_into (dest->vars, src->vars); } +void +pt_solution_add_var (struct pt_solution *dest, tree var) +{ + struct pt_solution var_pt; + pt_solution_set_var (&var_pt, var); + pt_solution_ior_into (dest, &var_pt); +} + /* Return true if the points-to solution *PT is empty. */ bool