OSDN Git Service

* gimplify.c (struct gimplify_ctx): Move to tree-gimple.h.
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 9 Jul 2008 19:32:54 +0000 (19:32 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 9 Jul 2008 19:32:54 +0000 (19:32 +0000)
(push_gimplify_context): Don't allocate temp_htab nor c itself here.
Add c argument.
(pop_gimplify_context): Check c->temp_htab instead of optimize whether
htab_delete should be called.  Don't free c.
(lookup_tmp_var): Create temp_htab lazily.
(gimplify_scan_omp_clauses, gimplify_omp_parallel, gimplify_omp_task,
gimplify_body, force_gimple_operand): Adjust push_gimplify_context
callers.
* omp-low.c (lower_omp_sections, lower_omp_single, lower_omp_master,
lower_omp_ordered, lower_omp_critical, lower_omp_for,
create_task_copyfn, lower_omp_taskreg, execute_lower_omp):
* tree-ssa-ccp.c (convert_to_gimple_builtin): Likewise.
* tree-sra.c (generate_element_init): Likewise.
* tree-mudflap.c (execute_mudflap_function_ops,
execute_mudflap_function_decls): Likewise.
* tree-inline.c (setup_one_parameter, optimize_inline_calls): Likewise.
* tree-gimple.h (struct gimplify_ctx): New type.
(push_gimplify_context): Adjust prototype.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@137666 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/gimplify.c
gcc/omp-low.c
gcc/tree-gimple.h
gcc/tree-inline.c
gcc/tree-mudflap.c
gcc/tree-sra.c
gcc/tree-ssa-ccp.c

index 1f8e3a9..4cb2cae 100644 (file)
@@ -1,3 +1,25 @@
+2008-07-09  Jakub Jelinek  <jakub@redhat.com>
+
+       * gimplify.c (struct gimplify_ctx): Move to tree-gimple.h.
+       (push_gimplify_context): Don't allocate temp_htab nor c itself here.
+       Add c argument.
+       (pop_gimplify_context): Check c->temp_htab instead of optimize whether
+       htab_delete should be called.  Don't free c.
+       (lookup_tmp_var): Create temp_htab lazily.
+       (gimplify_scan_omp_clauses, gimplify_omp_parallel, gimplify_omp_task,
+       gimplify_body, force_gimple_operand): Adjust push_gimplify_context
+       callers.
+       * omp-low.c (lower_omp_sections, lower_omp_single, lower_omp_master,
+       lower_omp_ordered, lower_omp_critical, lower_omp_for,
+       create_task_copyfn, lower_omp_taskreg, execute_lower_omp): 
+       * tree-ssa-ccp.c (convert_to_gimple_builtin): Likewise.
+       * tree-sra.c (generate_element_init): Likewise.
+       * tree-mudflap.c (execute_mudflap_function_ops,
+       execute_mudflap_function_decls): Likewise.
+       * tree-inline.c (setup_one_parameter, optimize_inline_calls): Likewise.
+       * tree-gimple.h (struct gimplify_ctx): New type.
+       (push_gimplify_context): Adjust prototype.
+
 2008-07-09  Daniel Berlin  <dberlin@dberlin.org>
 
        * tree-ssa-pre.c (phi_translate_1): Update placement of
index c3af34b..b6bc9ca 100644 (file)
@@ -85,26 +85,6 @@ struct gimplify_omp_ctx
   enum omp_region_type region_type;
 };
 
-struct gimplify_ctx
-{
-  struct gimplify_ctx *prev_context;
-
-  tree current_bind_expr;
-  tree temps;
-  tree conditional_cleanups;
-  tree exit_label;
-  tree return_temp;
-  
-  VEC(tree,heap) *case_labels;
-  /* The formal temporary table.  Should this be persistent?  */
-  htab_t temp_htab;
-
-  int conditions;
-  bool save_stack;
-  bool into_ssa;
-  bool allow_rhs_cond_expr;
-};
-
 static struct gimplify_ctx *gimplify_ctxp;
 static struct gimplify_omp_ctx *gimplify_omp_ctxp;
 
@@ -169,15 +149,10 @@ gimple_tree_eq (const void *p1, const void *p2)
 /* Set up a context for the gimplifier.  */
 
 void
-push_gimplify_context (void)
+push_gimplify_context (struct gimplify_ctx *c)
 {
-  struct gimplify_ctx *c;
-
-  c = (struct gimplify_ctx *) xcalloc (1, sizeof (struct gimplify_ctx));
+  memset (c, '\0', sizeof (*c));
   c->prev_context = gimplify_ctxp;
-  if (optimize)
-    c->temp_htab = htab_create (1000, gimple_tree_hash, gimple_tree_eq, free);
-
   gimplify_ctxp = c;
 }
 
@@ -202,9 +177,8 @@ pop_gimplify_context (tree body)
   else
     record_vars (c->temps);
 
-  if (optimize)
+  if (c->temp_htab)
     htab_delete (c->temp_htab);
-  free (c);
 }
 
 static void
@@ -575,6 +549,9 @@ lookup_tmp_var (tree val, bool is_formal)
       void **slot;
 
       elt.val = val;
+      if (gimplify_ctxp->temp_htab == NULL)
+        gimplify_ctxp->temp_htab
+         = htab_create (1000, gimple_tree_hash, gimple_tree_eq, free);
       slot = htab_find_slot (gimplify_ctxp->temp_htab, (void *)&elt, INSERT);
       if (*slot == NULL)
        {
@@ -5105,6 +5082,7 @@ gimplify_scan_omp_clauses (tree *list_p, tree *pre_p,
                           enum omp_region_type region_type)
 {
   struct gimplify_omp_ctx *ctx, *outer_ctx;
+  struct gimplify_ctx gctx;
   tree c;
 
   ctx = new_omp_context (region_type);
@@ -5161,10 +5139,10 @@ gimplify_scan_omp_clauses (tree *list_p, tree *pre_p,
              omp_add_variable (ctx, OMP_CLAUSE_REDUCTION_PLACEHOLDER (c),
                                GOVD_LOCAL | GOVD_SEEN);
              gimplify_omp_ctxp = ctx;
-             push_gimplify_context ();
+             push_gimplify_context (&gctx);
              gimplify_stmt (&OMP_CLAUSE_REDUCTION_INIT (c));
              pop_gimplify_context (OMP_CLAUSE_REDUCTION_INIT (c));
-             push_gimplify_context ();
+             push_gimplify_context (&gctx);
              gimplify_stmt (&OMP_CLAUSE_REDUCTION_MERGE (c));
              pop_gimplify_context (OMP_CLAUSE_REDUCTION_MERGE (c));
              gimplify_omp_ctxp = outer_ctx;
@@ -5173,7 +5151,7 @@ gimplify_scan_omp_clauses (tree *list_p, tree *pre_p,
                   && OMP_CLAUSE_LASTPRIVATE_STMT (c))
            {
              gimplify_omp_ctxp = ctx;
-             push_gimplify_context ();
+             push_gimplify_context (&gctx);
              if (TREE_CODE (OMP_CLAUSE_LASTPRIVATE_STMT (c)) != BIND_EXPR)
                {
                  tree bind = build3 (BIND_EXPR, void_type_node, NULL,
@@ -5396,13 +5374,14 @@ static enum gimplify_status
 gimplify_omp_parallel (tree *expr_p, tree *pre_p)
 {
   tree expr = *expr_p;
+  struct gimplify_ctx gctx;
 
   gimplify_scan_omp_clauses (&OMP_PARALLEL_CLAUSES (expr), pre_p,
                             OMP_PARALLEL_COMBINED (expr)
                             ? ORT_COMBINED_PARALLEL
                             : ORT_PARALLEL);
 
-  push_gimplify_context ();
+  push_gimplify_context (&gctx);
 
   gimplify_stmt (&OMP_PARALLEL_BODY (expr));
 
@@ -5425,10 +5404,11 @@ static enum gimplify_status
 gimplify_omp_task (tree *expr_p, tree *pre_p)
 {
   tree expr = *expr_p;
+  struct gimplify_ctx gctx;
 
   gimplify_scan_omp_clauses (&OMP_TASK_CLAUSES (expr), pre_p, ORT_TASK);
 
-  push_gimplify_context ();
+  push_gimplify_context (&gctx);
 
   gimplify_stmt (&OMP_TASK_BODY (expr));
 
@@ -6653,11 +6633,12 @@ gimplify_body (tree *body_p, tree fndecl, bool do_parms)
 {
   location_t saved_location = input_location;
   tree body, parm_stmts;
+  struct gimplify_ctx gctx;
 
   timevar_push (TV_TREE_GIMPLIFY);
 
   gcc_assert (gimplify_ctxp == NULL);
-  push_gimplify_context ();
+  push_gimplify_context (&gctx);
 
   /* Unshare most shared trees in the body and in that of any nested functions.
      It would seem we don't have to do this for nested functions because
@@ -6799,6 +6780,7 @@ force_gimple_operand (tree expr, tree *stmts, bool simple, tree var)
   tree t;
   enum gimplify_status ret;
   gimple_predicate gimple_test_f;
+  struct gimplify_ctx gctx;
 
   *stmts = NULL_TREE;
 
@@ -6807,7 +6789,7 @@ force_gimple_operand (tree expr, tree *stmts, bool simple, tree var)
 
   gimple_test_f = simple ? is_gimple_val : is_gimple_reg_rhs;
 
-  push_gimplify_context ();
+  push_gimplify_context (&gctx);
   gimplify_ctxp->into_ssa = gimple_in_ssa_p (cfun);
   gimplify_ctxp->allow_rhs_cond_expr = true;
 
index e568007..4378c43 100644 (file)
@@ -5281,10 +5281,11 @@ lower_omp_sections (tree *stmt_p, omp_context *ctx)
   tree t, dlist;
   tree_stmt_iterator tsi;
   unsigned i, len;
+  struct gimplify_ctx gctx;
 
   stmt = *stmt_p;
 
-  push_gimplify_context ();
+  push_gimplify_context (&gctx);
 
   dlist = NULL;
   ilist = NULL;
@@ -5482,8 +5483,9 @@ static void
 lower_omp_single (tree *stmt_p, omp_context *ctx)
 {
   tree t, bind, block, single_stmt = *stmt_p, dlist;
+  struct gimplify_ctx gctx;
 
-  push_gimplify_context ();
+  push_gimplify_context (&gctx);
 
   block = make_node (BLOCK);
   *stmt_p = bind = build3 (BIND_EXPR, void_type_node, NULL, NULL, block);
@@ -5526,8 +5528,9 @@ static void
 lower_omp_master (tree *stmt_p, omp_context *ctx)
 {
   tree bind, block, stmt = *stmt_p, lab = NULL, x;
+  struct gimplify_ctx gctx;
 
-  push_gimplify_context ();
+  push_gimplify_context (&gctx);
 
   block = make_node (BLOCK);
   *stmt_p = bind = build3 (BIND_EXPR, void_type_node, NULL, NULL, block);
@@ -5565,8 +5568,9 @@ static void
 lower_omp_ordered (tree *stmt_p, omp_context *ctx)
 {
   tree bind, block, stmt = *stmt_p, x;
+  struct gimplify_ctx gctx;
 
-  push_gimplify_context ();
+  push_gimplify_context (&gctx);
 
   block = make_node (BLOCK);
   *stmt_p = bind = build3 (BIND_EXPR, void_type_node, NULL, NULL, block);
@@ -5609,6 +5613,7 @@ lower_omp_critical (tree *stmt_p, omp_context *ctx)
 {
   tree bind, block, stmt = *stmt_p;
   tree t, lock, unlock, name;
+  struct gimplify_ctx gctx;
 
   name = OMP_CRITICAL_NAME (stmt);
   if (name)
@@ -5658,7 +5663,7 @@ lower_omp_critical (tree *stmt_p, omp_context *ctx)
       unlock = build_call_expr (unlock, 0);
     }
 
-  push_gimplify_context ();
+  push_gimplify_context (&gctx);
 
   block = make_node (BLOCK);
   *stmt_p = bind = build3 (BIND_EXPR, void_type_node, NULL, NULL, block);
@@ -5743,10 +5748,11 @@ lower_omp_for (tree *stmt_p, omp_context *ctx)
   tree t, stmt, ilist, dlist, new_stmt, block, *body_p, *rhs_p;
   struct omp_for_data fd;
   int i;
+  struct gimplify_ctx gctx;
 
   stmt = *stmt_p;
 
-  push_gimplify_context ();
+  push_gimplify_context (&gctx);
 
   lower_omp (&OMP_FOR_PRE_BODY (stmt), ctx);
   lower_omp (&OMP_FOR_BODY (stmt), ctx);
@@ -5909,6 +5915,7 @@ create_task_copyfn (tree task_stmt, omp_context *ctx)
   bool record_needs_remap = false, srecord_needs_remap = false;
   splay_tree_node n;
   struct omp_taskcopy_context tcctx;
+  struct gimplify_ctx gctx;
 
   child_fn = OMP_TASK_COPYFN (task_stmt);
   child_cfun = DECL_STRUCT_FUNCTION (child_fn);
@@ -5921,7 +5928,7 @@ create_task_copyfn (tree task_stmt, omp_context *ctx)
     DECL_CONTEXT (t) = child_fn;
 
   /* Populate the function.  */
-  push_gimplify_context ();
+  push_gimplify_context (&gctx);
   current_function_decl = child_fn;
 
   bind = build3 (BIND_EXPR, void_type_node, NULL, NULL, NULL);
@@ -6138,6 +6145,7 @@ lower_omp_taskreg (tree *stmt_p, omp_context *ctx)
   tree clauses, par_bind, par_body, new_body, bind;
   tree olist, ilist, par_olist, par_ilist;
   tree stmt, child_fn, t;
+  struct gimplify_ctx gctx;
 
   stmt = *stmt_p;
 
@@ -6161,7 +6169,7 @@ lower_omp_taskreg (tree *stmt_p, omp_context *ctx)
   if (ctx->srecord_type)
     create_task_copyfn (stmt, ctx);
 
-  push_gimplify_context ();
+  push_gimplify_context (&gctx);
 
   par_olist = NULL_TREE;
   par_ilist = NULL_TREE;
@@ -6422,8 +6430,10 @@ execute_lower_omp (void)
 
   if (all_contexts->root)
     {
+      struct gimplify_ctx gctx;
+
       if (task_shared_vars)
-       push_gimplify_context ();
+       push_gimplify_context (&gctx);
       lower_omp (&DECL_SAVED_TREE (current_function_decl), NULL);
       if (task_shared_vars)
        pop_gimplify_context (NULL);
index 3864d5d..3691cbc 100644 (file)
@@ -118,6 +118,26 @@ enum gimplify_status {
   GS_ALL_DONE  = 1     /* The expression is fully gimplified.  */
 };
 
+struct gimplify_ctx
+{
+  struct gimplify_ctx *prev_context;
+
+  tree current_bind_expr;
+  tree temps;
+  tree conditional_cleanups;
+  tree exit_label;
+  tree return_temp;
+  
+  VEC(tree,heap) *case_labels;
+  /* The formal temporary table.  Should this be persistent?  */
+  htab_t temp_htab;
+
+  int conditions;
+  bool save_stack;
+  bool into_ssa;
+  bool allow_rhs_cond_expr;
+};
+
 extern enum gimplify_status gimplify_expr (tree *, tree *, tree *,
                                           bool (*) (tree), fallback_t);
 extern void gimplify_type_sizes (tree, tree *);
@@ -125,7 +145,7 @@ extern void gimplify_one_sizepos (tree *, tree *);
 extern void gimplify_stmt (tree *);
 extern void gimplify_to_stmt_list (tree *);
 extern void gimplify_body (tree *, tree, bool);
-extern void push_gimplify_context (void);
+extern void push_gimplify_context (struct gimplify_ctx *);
 extern void pop_gimplify_context (tree);
 extern void gimplify_and_add (tree, tree *);
 
index 0f1a8bd..c0f4c88 100644 (file)
@@ -1590,8 +1590,9 @@ setup_one_parameter (copy_body_data *id, tree p, tree value, tree fn,
          || !is_gimple_reg (var))
        {
           tree_stmt_iterator i;
+          struct gimplify_ctx gctx;
 
-         push_gimplify_context ();
+         push_gimplify_context (&gctx);
          gimplify_stmt (&init_stmt);
          if (gimple_in_ssa_p (cfun)
               && init_stmt && TREE_CODE (init_stmt) == STATEMENT_LIST)
@@ -2986,6 +2987,8 @@ optimize_inline_calls (tree fn)
   tree prev_fn;
   basic_block bb;
   int last = n_basic_blocks;
+  struct gimplify_ctx gctx;
+
   /* There is no point in performing inlining if errors have already
      occurred -- and we might crash if we try to inline invalid
      code.  */
@@ -3012,7 +3015,7 @@ optimize_inline_calls (tree fn)
   id.transform_lang_insert_block = NULL;
   id.statements_to_fold = pointer_set_create ();
 
-  push_gimplify_context ();
+  push_gimplify_context (&gctx);
 
   /* We make no attempts to keep dominance info up-to-date.  */
   free_dominance_info (CDI_DOMINATORS);
index b5e8984..46650b3 100644 (file)
@@ -421,13 +421,15 @@ mudflap_init (void)
 static unsigned int
 execute_mudflap_function_ops (void)
 {
+  struct gimplify_ctx gctx;
+
   /* Don't instrument functions such as the synthetic constructor
      built during mudflap_finish_file.  */
   if (mf_marked_p (current_function_decl) ||
       DECL_ARTIFICIAL (current_function_decl))
     return 0;
 
-  push_gimplify_context ();
+  push_gimplify_context (&gctx);
 
   /* In multithreaded mode, don't cache the lookup cache parameters.  */
   if (! flag_mudflap_threads)
@@ -958,13 +960,15 @@ mf_xform_derefs (void)
 static unsigned int
 execute_mudflap_function_decls (void)
 {
+  struct gimplify_ctx gctx;
+
   /* Don't instrument functions such as the synthetic constructor
      built during mudflap_finish_file.  */
   if (mf_marked_p (current_function_decl) ||
       DECL_ARTIFICIAL (current_function_decl))
     return 0;
 
-  push_gimplify_context ();
+  push_gimplify_context (&gctx);
 
   mf_xform_decls (DECL_SAVED_TREE (current_function_decl),
                   DECL_ARGUMENTS (current_function_decl));
index 16f719e..21cf367 100644 (file)
@@ -2832,8 +2832,9 @@ static bool
 generate_element_init (struct sra_elt *elt, tree init, tree *list_p)
 {
   bool ret;
+  struct gimplify_ctx gctx;
 
-  push_gimplify_context ();
+  push_gimplify_context (&gctx);
   ret = generate_element_init_1 (elt, init, list_p);
   pop_gimplify_context (NULL);
 
index da6b785..3b90da4 100644 (file)
@@ -2825,8 +2825,9 @@ convert_to_gimple_builtin (block_stmt_iterator *si_p, tree expr, bool ignore)
   tree_stmt_iterator ti;
   tree stmt = bsi_stmt (*si_p);
   tree tmp, stmts = NULL;
+  struct gimplify_ctx gctx;
 
-  push_gimplify_context ();
+  push_gimplify_context (&gctx);
   if (ignore)
     {
       tmp = build_empty_stmt ();