Commit 57d598f7 by Sebastian Pop Committed by Sebastian Pop

Fix PR47127: call cloog_state_malloc and cloog_state_free only once.

2011-03-12  Sebastian Pop  <sebastian.pop@amd.com>

	PR tree-optimization/47127
	* graphite-clast-to-gimple.c (build_cloog_prog): Removed state
	parameter.
	(set_cloog_options): Same.
	(scop_to_clast): Same.
	(print_clast_stmt): Do not call cloog_state_malloc and
	cloog_state_free.
	(print_generated_program): Same.
	(gloog): Same.
	* graphite-clast-to-gimple.h (cloog_state): Declared.
	(scop_to_clast): Adjust declaration.
	* graphite.c (cloog_state): Defined here.
	(graphite_initialize): Call cloog_state_malloc.
	(graphite_finalize): Call cloog_state_free.

From-SVN: r170907
parent 2e49964f
2011-03-12 Sebastian Pop <sebastian.pop@amd.com>
PR tree-optimization/47127
* graphite-clast-to-gimple.c (build_cloog_prog): Removed state
parameter.
(set_cloog_options): Same.
(scop_to_clast): Same.
(print_clast_stmt): Do not call cloog_state_malloc and
cloog_state_free.
(print_generated_program): Same.
(gloog): Same.
* graphite-clast-to-gimple.h (cloog_state): Declared.
(scop_to_clast): Adjust declaration.
* graphite.c (cloog_state): Defined here.
(graphite_initialize): Call cloog_state_malloc.
(graphite_finalize): Call cloog_state_free.
2011-03-11 Jason Merrill <jason@redhat.com> 2011-03-11 Jason Merrill <jason@redhat.com>
* attribs.c (lookup_attribute_spec): Take const_tree. * attribs.c (lookup_attribute_spec): Take const_tree.
......
...@@ -1236,7 +1236,7 @@ init_cloog_input_file (int scop_number) ...@@ -1236,7 +1236,7 @@ init_cloog_input_file (int scop_number)
static void static void
build_cloog_prog (scop_p scop, CloogProgram *prog, build_cloog_prog (scop_p scop, CloogProgram *prog,
CloogOptions *options, CloogState *state ATTRIBUTE_UNUSED) CloogOptions *options)
{ {
int i; int i;
int max_nb_loops = scop_max_loop_depth (scop); int max_nb_loops = scop_max_loop_depth (scop);
...@@ -1249,7 +1249,7 @@ build_cloog_prog (scop_p scop, CloogProgram *prog, ...@@ -1249,7 +1249,7 @@ build_cloog_prog (scop_p scop, CloogProgram *prog,
cloog_program_set_context cloog_program_set_context
(prog, new_Cloog_Domain_from_ppl_Pointset_Powerset (SCOP_CONTEXT (scop), (prog, new_Cloog_Domain_from_ppl_Pointset_Powerset (SCOP_CONTEXT (scop),
scop_nb_params (scop), state)); scop_nb_params (scop), cloog_state));
nbs = unify_scattering_dimensions (scop); nbs = unify_scattering_dimensions (scop);
scaldims = (int *) xmalloc (nbs * (sizeof (int))); scaldims = (int *) xmalloc (nbs * (sizeof (int)));
cloog_program_set_nb_scattdims (prog, nbs); cloog_program_set_nb_scattdims (prog, nbs);
...@@ -1267,16 +1267,16 @@ build_cloog_prog (scop_p scop, CloogProgram *prog, ...@@ -1267,16 +1267,16 @@ build_cloog_prog (scop_p scop, CloogProgram *prog,
continue; continue;
/* Build the new statement and its block. */ /* Build the new statement and its block. */
stmt = cloog_statement_alloc (state, pbb_index (pbb)); stmt = cloog_statement_alloc (cloog_state, pbb_index (pbb));
dom = new_Cloog_Domain_from_ppl_Pointset_Powerset (PBB_DOMAIN (pbb), dom = new_Cloog_Domain_from_ppl_Pointset_Powerset (PBB_DOMAIN (pbb),
scop_nb_params (scop), scop_nb_params (scop),
state); cloog_state);
block = cloog_block_alloc (stmt, 0, NULL, pbb_dim_iter_domain (pbb)); block = cloog_block_alloc (stmt, 0, NULL, pbb_dim_iter_domain (pbb));
cloog_statement_set_usr (stmt, pbb); cloog_statement_set_usr (stmt, pbb);
/* Build loop list. */ /* Build loop list. */
{ {
CloogLoop *new_loop_list = cloog_loop_malloc (state); CloogLoop *new_loop_list = cloog_loop_malloc (cloog_state);
cloog_loop_set_next (new_loop_list, loop_list); cloog_loop_set_next (new_loop_list, loop_list);
cloog_loop_set_domain (new_loop_list, dom); cloog_loop_set_domain (new_loop_list, dom);
cloog_loop_set_block (new_loop_list, block); cloog_loop_set_block (new_loop_list, block);
...@@ -1303,7 +1303,7 @@ build_cloog_prog (scop_p scop, CloogProgram *prog, ...@@ -1303,7 +1303,7 @@ build_cloog_prog (scop_p scop, CloogProgram *prog,
scat = PBB_TRANSFORMED_SCATTERING (pbb); scat = PBB_TRANSFORMED_SCATTERING (pbb);
dom = new_Cloog_Scattering_from_ppl_Polyhedron dom = new_Cloog_Scattering_from_ppl_Polyhedron
(scat, scop_nb_params (scop), pbb_nb_scattering_transform (pbb), (scat, scop_nb_params (scop), pbb_nb_scattering_transform (pbb),
state); cloog_state);
cloog_set_next_scattering (new_scattering, scattering); cloog_set_next_scattering (new_scattering, scattering);
cloog_set_scattering (new_scattering, dom); cloog_set_scattering (new_scattering, dom);
...@@ -1360,9 +1360,9 @@ build_cloog_prog (scop_p scop, CloogProgram *prog, ...@@ -1360,9 +1360,9 @@ build_cloog_prog (scop_p scop, CloogProgram *prog,
/* Return the options that will be used in GLOOG. */ /* Return the options that will be used in GLOOG. */
static CloogOptions * static CloogOptions *
set_cloog_options (CloogState *state ATTRIBUTE_UNUSED) set_cloog_options (void)
{ {
CloogOptions *options = cloog_options_malloc (state); CloogOptions *options = cloog_options_malloc (cloog_state);
/* Change cloog output language to C. If we do use FORTRAN instead, cloog /* Change cloog output language to C. If we do use FORTRAN instead, cloog
will stop e.g. with "ERROR: unbounded loops not allowed in FORTRAN.", if will stop e.g. with "ERROR: unbounded loops not allowed in FORTRAN.", if
...@@ -1411,12 +1411,10 @@ set_cloog_options (CloogState *state ATTRIBUTE_UNUSED) ...@@ -1411,12 +1411,10 @@ set_cloog_options (CloogState *state ATTRIBUTE_UNUSED)
void void
print_clast_stmt (FILE *file, struct clast_stmt *stmt) print_clast_stmt (FILE *file, struct clast_stmt *stmt)
{ {
CloogState *state = cloog_state_malloc (); CloogOptions *options = set_cloog_options ();
CloogOptions *options = set_cloog_options (state);
clast_pprint (file, stmt, 0, options); clast_pprint (file, stmt, 0, options);
cloog_options_free (options); cloog_options_free (options);
cloog_state_free (state);
} }
/* Prints STMT to STDERR. */ /* Prints STMT to STDERR. */
...@@ -1432,14 +1430,14 @@ debug_clast_stmt (struct clast_stmt *stmt) ...@@ -1432,14 +1430,14 @@ debug_clast_stmt (struct clast_stmt *stmt)
without a program. */ without a program. */
cloog_prog_clast cloog_prog_clast
scop_to_clast (scop_p scop, CloogState *state) scop_to_clast (scop_p scop)
{ {
CloogOptions *options = set_cloog_options (state); CloogOptions *options = set_cloog_options ();
cloog_prog_clast pc; cloog_prog_clast pc;
/* Connect new cloog prog generation to graphite. */ /* Connect new cloog prog generation to graphite. */
pc.prog = cloog_program_malloc (); pc.prog = cloog_program_malloc ();
build_cloog_prog (scop, pc.prog, options, state); build_cloog_prog (scop, pc.prog, options);
pc.prog = cloog_program_generate (pc.prog, options); pc.prog = cloog_program_generate (pc.prog, options);
pc.stmt = cloog_clast_create (pc.prog, options); pc.stmt = cloog_clast_create (pc.prog, options);
...@@ -1452,10 +1450,9 @@ scop_to_clast (scop_p scop, CloogState *state) ...@@ -1452,10 +1450,9 @@ scop_to_clast (scop_p scop, CloogState *state)
void void
print_generated_program (FILE *file, scop_p scop) print_generated_program (FILE *file, scop_p scop)
{ {
CloogState *state = cloog_state_malloc (); CloogOptions *options = set_cloog_options ();
CloogOptions *options = set_cloog_options (state);
cloog_prog_clast pc = scop_to_clast (scop, state); cloog_prog_clast pc = scop_to_clast (scop);
fprintf (file, " (prog: \n"); fprintf (file, " (prog: \n");
cloog_program_print (file, pc.prog); cloog_program_print (file, pc.prog);
...@@ -1506,13 +1503,11 @@ gloog (scop_p scop, htab_t bb_pbb_mapping) ...@@ -1506,13 +1503,11 @@ gloog (scop_p scop, htab_t bb_pbb_mapping)
ifsese if_region = NULL; ifsese if_region = NULL;
htab_t newivs_index, params_index; htab_t newivs_index, params_index;
cloog_prog_clast pc; cloog_prog_clast pc;
CloogState *state;
state = cloog_state_malloc ();
timevar_push (TV_GRAPHITE_CODE_GEN); timevar_push (TV_GRAPHITE_CODE_GEN);
gloog_error = false; gloog_error = false;
pc = scop_to_clast (scop, state); pc = scop_to_clast (scop);
if (dump_file && (dump_flags & TDF_DETAILS)) if (dump_file && (dump_flags & TDF_DETAILS))
{ {
...@@ -1577,8 +1572,6 @@ gloog (scop_p scop, htab_t bb_pbb_mapping) ...@@ -1577,8 +1572,6 @@ gloog (scop_p scop, htab_t bb_pbb_mapping)
num_no_dependency); num_no_dependency);
} }
cloog_state_free (state);
return !gloog_error; return !gloog_error;
} }
#endif #endif
...@@ -22,6 +22,9 @@ along with GCC; see the file COPYING3. If not see ...@@ -22,6 +22,9 @@ along with GCC; see the file COPYING3. If not see
#define GCC_GRAPHITE_CLAST_TO_GIMPLE_H #define GCC_GRAPHITE_CLAST_TO_GIMPLE_H
#include "graphite-cloog-util.h" #include "graphite-cloog-util.h"
extern CloogState *cloog_state;
/* Data structure for CLooG program representation. */ /* Data structure for CLooG program representation. */
typedef struct cloog_prog_clast { typedef struct cloog_prog_clast {
...@@ -35,10 +38,10 @@ typedef struct bb_pbb_def ...@@ -35,10 +38,10 @@ typedef struct bb_pbb_def
{ {
basic_block bb; basic_block bb;
poly_bb_p pbb; poly_bb_p pbb;
}bb_pbb_def; } bb_pbb_def;
extern bool gloog (scop_p, htab_t); extern bool gloog (scop_p, htab_t);
extern cloog_prog_clast scop_to_clast (scop_p, CloogState *); extern cloog_prog_clast scop_to_clast (scop_p);
extern void debug_clast_stmt (struct clast_stmt *); extern void debug_clast_stmt (struct clast_stmt *);
extern void print_clast_stmt (FILE *, struct clast_stmt *); extern void print_clast_stmt (FILE *, struct clast_stmt *);
......
...@@ -54,6 +54,8 @@ along with GCC; see the file COPYING3. If not see ...@@ -54,6 +54,8 @@ along with GCC; see the file COPYING3. If not see
#include "graphite-clast-to-gimple.h" #include "graphite-clast-to-gimple.h"
#include "graphite-sese-to-poly.h" #include "graphite-sese-to-poly.h"
CloogState *cloog_state;
/* Print global statistics to FILE. */ /* Print global statistics to FILE. */
static void static void
...@@ -206,6 +208,7 @@ graphite_initialize (void) ...@@ -206,6 +208,7 @@ graphite_initialize (void)
ppl_initialized = ppl_initialize (); ppl_initialized = ppl_initialize ();
gcc_assert (ppl_initialized == 0); gcc_assert (ppl_initialized == 0);
cloog_state = cloog_state_malloc ();
cloog_initialize (); cloog_initialize ();
if (dump_file && dump_flags) if (dump_file && dump_flags)
...@@ -229,6 +232,7 @@ graphite_finalize (bool need_cfg_cleanup_p) ...@@ -229,6 +232,7 @@ graphite_finalize (bool need_cfg_cleanup_p)
tree_estimate_probability (); tree_estimate_probability ();
} }
cloog_state_free (cloog_state);
cloog_finalize (); cloog_finalize ();
ppl_finalize (); ppl_finalize ();
free_original_copy_tables (); free_original_copy_tables ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment