This is the mail archive of the gcc-patches@gcc.gnu.org mailing 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]

Re: [PATCH] Add PTA during early optimizations


Hi Richi,

is this not too costly for, say, a kernel compilation?

I wish there was a way to know a priori whether all these early opts
are helpfull for a given function...

Ciao,
Steven



On 5/25/09, Richard Guenther <rguenther@suse.de> wrote:
>
> This adds an early points-to analysis pass as requested by Honza.  I
> ended up not using the points-to set merging code as I have convinced
> myself that we can re-compute the local points-to solutions retaining
> results from IPA-PTA if we properly use per cgraph-node function infos
> and seed the local constraints with them (which of course remains to
> be done).  The patch also merges correctness pieces from the earlier
> attempt.
>
> Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
>
> Richard.
>
> 2009-05-25  Richard Guenther  <rguenther@suse.de>
>
> 	* tree-ssa-alias.h (dump_points_to_solution): Declare.
> 	* tree-inline.c (expand_call_inline): Reset the escaped and
> 	callused solutions.
> 	* tree-ssa-structalias.c (pass_build_ealias): New.
> 	* tree-pass.h (pass_build_ealias): Declare.
> 	* passes.c (init_optimization_passes): Add PTA during
> 	early optimizations.
> 	* tree-ssa-alias.c (dump_alias_info): Dump the ESCAPED
> 	and CALLUSED solutions.
> 	(dump_points_to_solution): New function, split out from ...
> 	(dump_points_to_info_for): ... here.
> 	* tree-parloops.c (parallelize_loops): Reset the escaped and
> 	callused solutions.
>
> 	* gcc.dg/tree-ssa/ssa-fre-14.c: Adjust.
> 	* gcc.dg/tree-ssa/ssa-fre-15.c: Likewise.
>
> Index: gcc/tree-ssa-alias.h
> ===================================================================
> *** gcc/tree-ssa-alias.h.orig	2009-05-25 12:41:08.000000000 +0200
> --- gcc/tree-ssa-alias.h	2009-05-25 12:46:25.000000000 +0200
> *************** extern unsigned int walk_aliased_vdefs (
> *** 90,95 ****
> --- 90,96 ----
>   extern struct ptr_info_def *get_ptr_info (tree);
>   extern void dump_alias_info (FILE *);
>   extern void debug_alias_info (void);
> + extern void dump_points_to_solution (FILE *, struct pt_solution *);
>   extern void dump_points_to_info_for (FILE *, tree);
>   extern void debug_points_to_info_for (tree);
>   extern void dump_alias_stats (FILE *);
> Index: gcc/tree-inline.c
> ===================================================================
> *** gcc/tree-inline.c.orig	2009-05-25 12:41:08.000000000 +0200
> --- gcc/tree-inline.c	2009-05-25 12:47:44.000000000 +0200
> *************** expand_call_inline (basic_block bb, gimp
> *** 3451,3456 ****
> --- 3451,3463 ----
>        duplicate our body before altering anything.  */
>     copy_body (id, bb->count, bb->frequency, bb, return_block);
>
> +   /* Reset the escaped and callused solutions.  */
> +   if (cfun->gimple_df)
> +     {
> +       pt_solution_reset (&cfun->gimple_df->escaped);
> +       pt_solution_reset (&cfun->gimple_df->callused);
> +     }
> +
>     /* Clean up.  */
>     pointer_map_destroy (id->decl_map);
>     id->decl_map = st;
> Index: gcc/passes.c
> ===================================================================
> *** gcc/passes.c.orig	2009-05-25 12:41:09.000000000 +0200
> --- gcc/passes.c	2009-05-25 13:30:07.000000000 +0200
> *************** init_optimization_passes (void)
> *** 554,560 ****
>   	  NEXT_PASS (pass_rename_ssa_copies);
>   	  NEXT_PASS (pass_ccp);
>   	  NEXT_PASS (pass_forwprop);
> ! 	  NEXT_PASS (pass_update_address_taken);
>   	  NEXT_PASS (pass_sra_early);
>   	  NEXT_PASS (pass_copy_prop);
>   	  NEXT_PASS (pass_merge_phi);
> --- 554,564 ----
>   	  NEXT_PASS (pass_rename_ssa_copies);
>   	  NEXT_PASS (pass_ccp);
>   	  NEXT_PASS (pass_forwprop);
> ! 	  /* pass_build_ealias is a dummy pass that ensures that we
> ! 	     execute TODO_rebuild_alias at this point.  Re-building
> ! 	     alias information also rewrites no longer addressed
> ! 	     locals into SSA form if possible.  */
> ! 	  NEXT_PASS (pass_build_ealias);
>   	  NEXT_PASS (pass_sra_early);
>   	  NEXT_PASS (pass_copy_prop);
>   	  NEXT_PASS (pass_merge_phi);
> Index: gcc/tree-ssa-alias.c
> ===================================================================
> *** gcc/tree-ssa-alias.c.orig	2009-05-25 12:41:08.000000000 +0200
> --- gcc/tree-ssa-alias.c	2009-05-25 12:46:25.000000000 +0200
> *************** dump_alias_info (FILE *file)
> *** 330,336 ****
>   	dump_variable (file, var);
>       }
>
> !   fprintf (file, "\n\nFlow-insensitive points-to information for %s\n\n",
> funcname);
>
>     for (i = 1; i < num_ssa_names; i++)
>       {
> --- 330,343 ----
>   	dump_variable (file, var);
>       }
>
> !   fprintf (file, "\nCall clobber information\n");
> !
> !   fprintf (file, "\nESCAPED");
> !   dump_points_to_solution (file, &cfun->gimple_df->escaped);
> !   fprintf (file, "\nCALLUSED");
> !   dump_points_to_solution (file, &cfun->gimple_df->callused);
> !
> !   fprintf (file, "\n\nFlow-insensitive points-to information\n\n");
>
>     for (i = 1; i < num_ssa_names; i++)
>       {
> *************** get_ptr_info (tree t)
> *** 380,385 ****
> --- 387,418 ----
>     return pi;
>   }
>
> + /* Dump the points-to set *PT into FILE.  */
> +
> + void
> + dump_points_to_solution (FILE *file, struct pt_solution *pt)
> + {
> +   if (pt->anything)
> +     fprintf (file, ", points-to anything");
> +
> +   if (pt->nonlocal)
> +     fprintf (file, ", points-to non-local");
> +
> +   if (pt->escaped)
> +     fprintf (file, ", points-to escaped");
> +
> +   if (pt->null)
> +     fprintf (file, ", points-to NULL");
> +
> +   if (pt->vars)
> +     {
> +       fprintf (file, ", points-to vars: ");
> +       dump_decl_set (file, pt->vars);
> +       if (pt->vars_contains_global)
> + 	fprintf (file, " (includes global vars)");
> +     }
> + }
> +
>   /* Dump points-to information for SSA_NAME PTR into FILE.  */
>
>   void
> *************** dump_points_to_info_for (FILE *file, tre
> *** 390,416 ****
>     print_generic_expr (file, ptr, dump_flags);
>
>     if (pi)
> !     {
> !       if (pi->pt.anything)
> ! 	fprintf (file, ", points-to anything");
> !
> !       if (pi->pt.nonlocal)
> ! 	fprintf (file, ", points-to non-local");
> !
> !       if (pi->pt.escaped)
> ! 	fprintf (file, ", points-to escaped");
> !
> !       if (pi->pt.null)
> ! 	fprintf (file, ", points-to NULL");
> !
> !       if (pi->pt.vars)
> ! 	{
> ! 	  fprintf (file, ", points-to vars: ");
> ! 	  dump_decl_set (file, pi->pt.vars);
> ! 	  if (pi->pt.vars_contains_global)
> ! 	    fprintf (file, " (includes global vars)");
> ! 	}
> !     }
>
>     fprintf (file, "\n");
>   }
> --- 423,431 ----
>     print_generic_expr (file, ptr, dump_flags);
>
>     if (pi)
> !     dump_points_to_solution (file, &pi->pt);
> !   else
> !     fprintf (file, ", points-to anything");
>
>     fprintf (file, "\n");
>   }
> Index: gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-14.c
> ===================================================================
> *** gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-14.c.orig	2009-05-20
> 16:19:05.000000000 +0200
> --- gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-14.c	2009-05-25 12:46:25.000000000
> +0200
> *************** struct Foo
> *** 8,13 ****
> --- 8,14 ----
>     void *data;
>     double size;
>   };
> + void bar(double *);
>   void foo(double (*q)[4])
>   {
>     struct Foo tmp1;
> *************** void foo(double (*q)[4])
> *** 23,28 ****
> --- 24,30 ----
>    	 this store to tmp1 here.  */
>         tmp1.size -= 1.0;
>       }
> +   bar(a);
>   }
>
>   /* { dg-final { scan-tree-dump "Inserted .* &a" "fre" } } */
> Index: gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-15.c
> ===================================================================
> *** gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-15.c.orig	2009-05-20
> 16:19:05.000000000 +0200
> --- gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-15.c	2009-05-25 12:46:25.000000000
> +0200
> *************** struct Foo
> *** 8,13 ****
> --- 8,14 ----
>     void *data;
>     double size;
>   };
> + void bar(double *);
>   void foo(double (*q)[4])
>   {
>     struct Foo tmp1;
> *************** void foo(double (*q)[4])
> *** 22,27 ****
> --- 23,29 ----
>    	 this store to tmp1 here.  */
>         tmp1.size -= 1.0;
>       }
> +   bar(a);
>   }
>
>   /* { dg-final { scan-tree-dump "Replaced" "fre" } } */
> Index: gcc/tree-parloops.c
> ===================================================================
> *** gcc/tree-parloops.c.orig	2009-05-20 16:19:05.000000000 +0200
> --- gcc/tree-parloops.c	2009-05-25 12:46:25.000000000 +0200
> *************** parallelize_loops (void)
> *** 1886,1891 ****
> --- 1886,1901 ----
>
>     free_stmt_vec_info_vec ();
>     htab_delete (reduction_list);
> +
> +   /* Parallelization will cause new function calls to be inserted through
> +      which local variables will escape.  Reset the points-to solutions
> +      for ESCAPED and CALLUSED.  */
> +   if (changed)
> +     {
> +       pt_solution_reset (&cfun->gimple_df->escaped);
> +       pt_solution_reset (&cfun->gimple_df->callused);
> +     }
> +
>     return changed;
>   }
>
> Index: gcc/tree-pass.h
> ===================================================================
> *** gcc/tree-pass.h.orig	2009-05-25 12:41:08.000000000 +0200
> --- gcc/tree-pass.h	2009-05-25 13:31:06.000000000 +0200
> *************** extern struct gimple_opt_pass pass_ccp;
> *** 350,355 ****
> --- 350,356 ----
>   extern struct gimple_opt_pass pass_phi_only_cprop;
>   extern struct gimple_opt_pass pass_build_ssa;
>   extern struct gimple_opt_pass pass_build_alias;
> + extern struct gimple_opt_pass pass_build_ealias;
>   extern struct gimple_opt_pass pass_dominator;
>   extern struct gimple_opt_pass pass_dce;
>   extern struct gimple_opt_pass pass_dce_loop;
> Index: gcc/tree-ssa-structalias.c
> ===================================================================
> *** gcc/tree-ssa-structalias.c.orig	2009-05-25 12:41:09.000000000 +0200
> --- gcc/tree-ssa-structalias.c	2009-05-25 13:30:42.000000000 +0200
> *************** struct gimple_opt_pass pass_build_alias
> *** 5436,5441 ****
> --- 5436,5463 ----
>    }
>   };
>
> + /* A dummy pass to cause points-to information to be computed via
> +    TODO_rebuild_alias.  */
> +
> + struct gimple_opt_pass pass_build_ealias =
> + {
> +  {
> +   GIMPLE_PASS,
> +   "ealias",		    /* name */
> +   gate_tree_pta,	    /* gate */
> +   NULL,                     /* execute */
> +   NULL,                     /* sub */
> +   NULL,                     /* next */
> +   0,                        /* static_pass_number */
> +   TV_NONE,                  /* tv_id */
> +   PROP_cfg | PROP_ssa,      /* properties_required */
> +   0,			    /* properties_provided */
> +   0,                        /* properties_destroyed */
> +   0,                        /* todo_flags_start */
> +   TODO_rebuild_alias | TODO_dump_func  /* todo_flags_finish */
> +  }
> + };
> +
>
>   /* Return true if we should execute IPA PTA.  */
>   static bool
>


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