Hi, This patch gets rid of some easy gimple_seq_alloc calls that we don't even need currently because most gimple_seq modifier will lazily allocate one. Most of the time it's enough to simply initialize a seq to NULL and call the respective routines like gimple_seq_add_{stmt,seq}. (A notable exception is when the seq will be used in an iterator).
As per [0/6] regstrapped together with the other five patches on x86_64-linux. Okay for trunk? Ciao, Michael. ------------------------ 2012-05-02 Michael Matz <m...@suse.de> * tree-phinodes.c (add_phi_node_to_bb): Tidy, don't use gimple_seq_alloc. * omp-low.c (finalize_task_copyfn): Don't use gimple_seq_alloc. * tree-nested.c (walk_gimple_omp_for): Ditto. * trans-mem.c (lower_transaction): Ditto. * tree-eh.c (do_return_redirection): Ditto. (do_goto_redirection): Ditto. (lower_try_finally_switch): Ditto. * gimplify.c (gimplify_stmt): Ditto. (gimplify_scan_omp_clauses): Ditto. (gimplify_omp_for): Ditto. (gimplify_function_tree): Ditto. * gimple-fold.c (gimplify_and_update_call_from_tree): Ditto. * tree-mudflap.c (mf_decl_cache_locals): Ditto. (mf_build_check_statement_for): Ditto. (mx_register_decls): Ditto. * graphite-sese-to-poly.c (remove_invariant_phi): Ditto, and don't use itertors to append. (insert_stmts): Ditto. (insert_out_of_ssa_copy): Ditto. (insert_out_of_ssa_copy_on_edge): Ditto. Index: tree-phinodes.c =================================================================== *** tree-phinodes.c.orig 2012-05-01 22:43:34.000000000 +0200 --- tree-phinodes.c 2012-05-01 22:43:55.000000000 +0200 *************** reserve_phi_args_for_new_edge (basic_blo *** 356,368 **** void add_phi_node_to_bb (gimple phi, basic_block bb) { ! gimple_stmt_iterator gsi; /* Add the new PHI node to the list of PHI nodes for block BB. */ ! if (phi_nodes (bb) == NULL) ! set_phi_nodes (bb, gimple_seq_alloc ()); ! ! gsi = gsi_last (phi_nodes (bb)); ! gsi_insert_after (&gsi, phi, GSI_NEW_STMT); /* Associate BB to the PHI node. */ gimple_set_bb (phi, bb); --- 356,370 ---- void add_phi_node_to_bb (gimple phi, basic_block bb) { ! gimple_seq seq = phi_nodes (bb); /* Add the new PHI node to the list of PHI nodes for block BB. */ ! if (seq == NULL) ! set_phi_nodes (bb, gimple_seq_alloc_with_stmt (phi)); ! else ! { ! gimple_seq_add_stmt (&seq, phi); ! gcc_assert (seq == phi_nodes (bb)); ! } /* Associate BB to the PHI node. */ gimple_set_bb (phi, bb); Index: omp-low.c =================================================================== *** omp-low.c.orig 2012-05-01 22:43:34.000000000 +0200 --- omp-low.c 2012-05-01 22:43:55.000000000 +0200 *************** finalize_task_copyfn (gimple task_stmt) *** 1231,1237 **** { struct function *child_cfun; tree child_fn, old_fn; ! gimple_seq seq, new_seq; gimple bind; child_fn = gimple_omp_task_copy_fn (task_stmt); --- 1231,1237 ---- { struct function *child_cfun; tree child_fn, old_fn; ! gimple_seq seq = NULL, new_seq; gimple bind; child_fn = gimple_omp_task_copy_fn (task_stmt); *************** finalize_task_copyfn (gimple task_stmt) *** 1248,1260 **** push_cfun (child_cfun); current_function_decl = child_fn; bind = gimplify_body (child_fn, false); - seq = gimple_seq_alloc (); gimple_seq_add_stmt (&seq, bind); new_seq = maybe_catch_exception (seq); if (new_seq != seq) { bind = gimple_build_bind (NULL, new_seq, NULL); ! seq = gimple_seq_alloc (); gimple_seq_add_stmt (&seq, bind); } gimple_set_body (child_fn, seq); --- 1248,1259 ---- push_cfun (child_cfun); current_function_decl = child_fn; bind = gimplify_body (child_fn, false); gimple_seq_add_stmt (&seq, bind); new_seq = maybe_catch_exception (seq); if (new_seq != seq) { bind = gimple_build_bind (NULL, new_seq, NULL); ! seq = NULL; gimple_seq_add_stmt (&seq, bind); } gimple_set_body (child_fn, seq); Index: tree-nested.c =================================================================== *** tree-nested.c.orig 2012-05-01 22:43:34.000000000 +0200 --- tree-nested.c 2012-05-01 22:43:55.000000000 +0200 *************** walk_gimple_omp_for (gimple for_stmt, *** 617,623 **** walk_body (callback_stmt, callback_op, info, gimple_omp_for_pre_body_ptr (for_stmt)); ! seq = gimple_seq_alloc (); memset (&wi, 0, sizeof (wi)); wi.info = info; wi.gsi = gsi_last (seq); --- 617,623 ---- walk_body (callback_stmt, callback_op, info, gimple_omp_for_pre_body_ptr (for_stmt)); ! seq = NULL; memset (&wi, 0, sizeof (wi)); wi.info = info; wi.gsi = gsi_last (seq); *************** walk_gimple_omp_for (gimple for_stmt, *** 646,654 **** walk_tree (&TREE_OPERAND (t, 1), callback_op, &wi, NULL); } ! if (gimple_seq_empty_p (seq)) ! gimple_seq_free (seq); ! else { gimple_seq pre_body = gimple_omp_for_pre_body (for_stmt); annotate_all_with_location (seq, gimple_location (for_stmt)); --- 646,653 ---- walk_tree (&TREE_OPERAND (t, 1), callback_op, &wi, NULL); } ! seq = gsi_seq (wi.gsi); ! if (!gimple_seq_empty_p (seq)) { gimple_seq pre_body = gimple_omp_for_pre_body (for_stmt); annotate_all_with_location (seq, gimple_location (for_stmt)); Index: trans-mem.c =================================================================== *** trans-mem.c.orig 2012-05-01 22:43:34.000000000 +0200 --- trans-mem.c 2012-05-01 22:43:55.000000000 +0200 *************** lower_transaction (gimple_stmt_iterator *** 1600,1606 **** gimple_seq n_seq, e_seq; n_seq = gimple_seq_alloc_with_stmt (g); ! e_seq = gimple_seq_alloc (); g = gimple_build_call (builtin_decl_explicit (BUILT_IN_EH_POINTER), 1, integer_zero_node); --- 1600,1606 ---- gimple_seq n_seq, e_seq; n_seq = gimple_seq_alloc_with_stmt (g); ! e_seq = NULL; g = gimple_build_call (builtin_decl_explicit (BUILT_IN_EH_POINTER), 1, integer_zero_node); Index: tree-eh.c =================================================================== *** tree-eh.c.orig 2012-05-01 22:43:34.000000000 +0200 --- tree-eh.c 2012-05-01 22:43:55.000000000 +0200 *************** do_return_redirection (struct goto_queue *** 731,739 **** q->cont_stmt = q->stmt.g; - if (!q->repl_stmt) - q->repl_stmt = gimple_seq_alloc (); - if (mod) gimple_seq_add_seq (&q->repl_stmt, mod); --- 731,736 ---- *************** do_goto_redirection (struct goto_queue_n *** 750,757 **** gimple x; gcc_assert (q->is_label); - if (!q->repl_stmt) - q->repl_stmt = gimple_seq_alloc (); q->cont_stmt = gimple_build_goto (VEC_index (tree, tf->dest_array, q->index)); --- 747,752 ---- *************** lower_try_finally_switch (struct leh_sta *** 1306,1312 **** int nlabels, ndests, j, last_case_index; tree last_case; VEC (tree,heap) *case_label_vec; ! gimple_seq switch_body; gimple x, eh_else; tree tmp; gimple switch_stmt; --- 1301,1307 ---- int nlabels, ndests, j, last_case_index; tree last_case; VEC (tree,heap) *case_label_vec; ! gimple_seq switch_body = NULL; gimple x, eh_else; tree tmp; gimple switch_stmt; *************** lower_try_finally_switch (struct leh_sta *** 1317,1323 **** /* The location of the finally block. */ location_t finally_loc; - switch_body = gimple_seq_alloc (); finally = gimple_try_cleanup (tf->top_p); eh_else = get_eh_else (finally); --- 1312,1317 ---- *************** lower_try_finally_switch (struct leh_sta *** 1426,1437 **** entrance through a particular edge. */ for (; q < qe; ++q) { ! gimple_seq mod; int switch_id; unsigned int case_index; - mod = gimple_seq_alloc (); - if (q->index < 0) { x = gimple_build_assign (finally_tmp, --- 1420,1429 ---- entrance through a particular edge. */ for (; q < qe; ++q) { ! gimple_seq mod = NULL; int switch_id; unsigned int case_index; if (q->index < 0) { x = gimple_build_assign (finally_tmp, Index: gimplify.c =================================================================== *** gimplify.c.orig 2012-05-01 22:39:07.000000000 +0200 --- gimplify.c 2012-05-01 22:43:55.000000000 +0200 *************** gimplify_stmt (tree *stmt_p, gimple_seq *** 5607,5615 **** { gimple_seq_node last; - if (!*seq_p) - *seq_p = gimple_seq_alloc (); - last = gimple_seq_last (*seq_p); gimplify_expr (stmt_p, seq_p, NULL, is_gimple_stmt, fb_none); return last != gimple_seq_last (*seq_p); --- 5607,5612 ---- *************** gimplify_scan_omp_clauses (tree *list_p, *** 6106,6113 **** gimplify_omp_ctxp = ctx; push_gimplify_context (&gctx); ! OMP_CLAUSE_REDUCTION_GIMPLE_INIT (c) = gimple_seq_alloc (); ! OMP_CLAUSE_REDUCTION_GIMPLE_MERGE (c) = gimple_seq_alloc (); gimplify_and_add (OMP_CLAUSE_REDUCTION_INIT (c), &OMP_CLAUSE_REDUCTION_GIMPLE_INIT (c)); --- 6103,6110 ---- gimplify_omp_ctxp = ctx; push_gimplify_context (&gctx); ! OMP_CLAUSE_REDUCTION_GIMPLE_INIT (c) = NULL; ! OMP_CLAUSE_REDUCTION_GIMPLE_MERGE (c) = NULL; gimplify_and_add (OMP_CLAUSE_REDUCTION_INIT (c), &OMP_CLAUSE_REDUCTION_GIMPLE_INIT (c)); *************** gimplify_omp_for (tree *expr_p, gimple_s *** 6443,6449 **** gimplify_and_add (OMP_FOR_PRE_BODY (for_stmt), &for_pre_body); OMP_FOR_PRE_BODY (for_stmt) = NULL_TREE; ! for_body = gimple_seq_alloc (); gcc_assert (TREE_VEC_LENGTH (OMP_FOR_INIT (for_stmt)) == TREE_VEC_LENGTH (OMP_FOR_COND (for_stmt))); gcc_assert (TREE_VEC_LENGTH (OMP_FOR_INIT (for_stmt)) --- 6440,6446 ---- gimplify_and_add (OMP_FOR_PRE_BODY (for_stmt), &for_pre_body); OMP_FOR_PRE_BODY (for_stmt) = NULL_TREE; ! for_body = NULL; gcc_assert (TREE_VEC_LENGTH (OMP_FOR_INIT (for_stmt)) == TREE_VEC_LENGTH (OMP_FOR_COND (for_stmt))); gcc_assert (TREE_VEC_LENGTH (OMP_FOR_INIT (for_stmt)) *************** gimplify_function_tree (tree fndecl) *** 8279,8285 **** /* The tree body of the function is no longer needed, replace it with the new GIMPLE body. */ ! seq = gimple_seq_alloc (); gimple_seq_add_stmt (&seq, bind); gimple_set_body (fndecl, seq); --- 8276,8282 ---- /* The tree body of the function is no longer needed, replace it with the new GIMPLE body. */ ! seq = NULL; gimple_seq_add_stmt (&seq, bind); gimple_set_body (fndecl, seq); *************** gimplify_function_tree (tree fndecl) *** 8328,8334 **** /* Replace the current function body with the body wrapped in the try/finally TF. */ ! seq = gimple_seq_alloc (); gimple_seq_add_stmt (&seq, new_bind); gimple_set_body (fndecl, seq); } --- 8325,8331 ---- /* Replace the current function body with the body wrapped in the try/finally TF. */ ! seq = NULL; gimple_seq_add_stmt (&seq, new_bind); gimple_set_body (fndecl, seq); } Index: gimple-fold.c =================================================================== *** gimple-fold.c.orig 2012-05-01 22:39:07.000000000 +0200 --- gimple-fold.c 2012-05-01 22:43:55.000000000 +0200 *************** gimplify_and_update_call_from_tree (gimp *** 549,555 **** tree lhs; gimple stmt, new_stmt; gimple_stmt_iterator i; ! gimple_seq stmts = gimple_seq_alloc(); struct gimplify_ctx gctx; gimple last; gimple laststore; --- 549,555 ---- tree lhs; gimple stmt, new_stmt; gimple_stmt_iterator i; ! gimple_seq stmts = NULL; struct gimplify_ctx gctx; gimple last; gimple laststore; Index: graphite-sese-to-poly.c =================================================================== *** graphite-sese-to-poly.c.orig 2012-05-01 22:39:07.000000000 +0200 --- graphite-sese-to-poly.c 2012-05-01 22:43:55.000000000 +0200 *************** remove_invariant_phi (sese region, gimpl *** 87,94 **** edge e = gimple_phi_arg_edge (phi, entry); tree var; gimple stmt; ! gimple_seq stmts; ! gimple_stmt_iterator gsi; if (tree_contains_chrecs (scev, NULL)) scev = gimple_phi_arg_def (phi, entry); --- 87,93 ---- edge e = gimple_phi_arg_edge (phi, entry); tree var; gimple stmt; ! gimple_seq stmts = NULL; if (tree_contains_chrecs (scev, NULL)) scev = gimple_phi_arg_def (phi, entry); *************** remove_invariant_phi (sese region, gimpl *** 97,107 **** stmt = gimple_build_assign (res, var); remove_phi_node (psi, false); ! if (!stmts) ! stmts = gimple_seq_alloc (); ! ! gsi = gsi_last (stmts); ! gsi_insert_after (&gsi, stmt, GSI_NEW_STMT); gsi_insert_seq_on_edge (e, stmts); gsi_commit_edge_inserts (); SSA_NAME_DEF_STMT (res) = stmt; --- 96,102 ---- stmt = gimple_build_assign (res, var); remove_phi_node (psi, false); ! gimple_seq_add_stmt (&stmts, stmt); gsi_insert_seq_on_edge (e, stmts); gsi_commit_edge_inserts (); SSA_NAME_DEF_STMT (res) = stmt; *************** insert_stmts (scop_p scop, gimple stmt, *** 2088,2098 **** gimple_stmt_iterator gsi; VEC (gimple, heap) *x = VEC_alloc (gimple, heap, 3); ! if (!stmts) ! stmts = gimple_seq_alloc (); ! ! gsi = gsi_last (stmts); ! gsi_insert_after (&gsi, stmt, GSI_NEW_STMT); for (gsi = gsi_start (stmts); !gsi_end_p (gsi); gsi_next (&gsi)) VEC_safe_push (gimple, heap, x, gsi_stmt (gsi)); --- 2083,2089 ---- gimple_stmt_iterator gsi; VEC (gimple, heap) *x = VEC_alloc (gimple, heap, 3); ! gimple_seq_add_stmt (&stmts, stmt); for (gsi = gsi_start (stmts); !gsi_end_p (gsi); gsi_next (&gsi)) VEC_safe_push (gimple, heap, x, gsi_stmt (gsi)); *************** static void *** 2107,2122 **** insert_out_of_ssa_copy (scop_p scop, tree res, tree expr, gimple after_stmt) { gimple_seq stmts; - gimple_stmt_iterator si; gimple_stmt_iterator gsi; tree var = force_gimple_operand (expr, &stmts, true, NULL_TREE); gimple stmt = gimple_build_assign (res, var); VEC (gimple, heap) *x = VEC_alloc (gimple, heap, 3); ! if (!stmts) ! stmts = gimple_seq_alloc (); ! si = gsi_last (stmts); ! gsi_insert_after (&si, stmt, GSI_NEW_STMT); for (gsi = gsi_start (stmts); !gsi_end_p (gsi); gsi_next (&gsi)) VEC_safe_push (gimple, heap, x, gsi_stmt (gsi)); --- 2098,2109 ---- insert_out_of_ssa_copy (scop_p scop, tree res, tree expr, gimple after_stmt) { gimple_seq stmts; gimple_stmt_iterator gsi; tree var = force_gimple_operand (expr, &stmts, true, NULL_TREE); gimple stmt = gimple_build_assign (res, var); VEC (gimple, heap) *x = VEC_alloc (gimple, heap, 3); ! gimple_seq_add_stmt (&stmts, stmt); for (gsi = gsi_start (stmts); !gsi_end_p (gsi); gsi_next (&gsi)) VEC_safe_push (gimple, heap, x, gsi_stmt (gsi)); *************** static void *** 2167,2183 **** insert_out_of_ssa_copy_on_edge (scop_p scop, edge e, tree res, tree expr) { gimple_stmt_iterator gsi; ! gimple_seq stmts; tree var = force_gimple_operand (expr, &stmts, true, NULL_TREE); gimple stmt = gimple_build_assign (res, var); basic_block bb; VEC (gimple, heap) *x = VEC_alloc (gimple, heap, 3); ! if (!stmts) ! stmts = gimple_seq_alloc (); ! ! gsi = gsi_last (stmts); ! gsi_insert_after (&gsi, stmt, GSI_NEW_STMT); for (gsi = gsi_start (stmts); !gsi_end_p (gsi); gsi_next (&gsi)) VEC_safe_push (gimple, heap, x, gsi_stmt (gsi)); --- 2154,2166 ---- insert_out_of_ssa_copy_on_edge (scop_p scop, edge e, tree res, tree expr) { gimple_stmt_iterator gsi; ! gimple_seq stmts = NULL; tree var = force_gimple_operand (expr, &stmts, true, NULL_TREE); gimple stmt = gimple_build_assign (res, var); basic_block bb; VEC (gimple, heap) *x = VEC_alloc (gimple, heap, 3); ! gimple_seq_add_stmt (&stmts, stmt); for (gsi = gsi_start (stmts); !gsi_end_p (gsi); gsi_next (&gsi)) VEC_safe_push (gimple, heap, x, gsi_stmt (gsi)); Index: tree-mudflap.c =================================================================== *** tree-mudflap.c.orig 2012-05-01 22:39:07.000000000 +0200 --- tree-mudflap.c 2012-05-01 22:43:55.000000000 +0200 *************** static void *** 472,478 **** mf_decl_cache_locals (void) { gimple g; ! gimple_seq seq = gimple_seq_alloc (); /* Build the cache vars. */ mf_cache_shift_decl_l --- 472,478 ---- mf_decl_cache_locals (void) { gimple g; ! gimple_seq seq = NULL; /* Build the cache vars. */ mf_cache_shift_decl_l *************** mf_build_check_statement_for (tree base, *** 572,578 **** mf_limit = make_rename_temp (mf_uintptr_type, "__mf_limit"); /* Build: __mf_base = (uintptr_t) <base address expression>. */ ! seq = gimple_seq_alloc (); t = fold_convert_loc (location, mf_uintptr_type, unshare_expr (base)); t = force_gimple_operand (t, &stmts, false, NULL_TREE); --- 572,578 ---- mf_limit = make_rename_temp (mf_uintptr_type, "__mf_limit"); /* Build: __mf_base = (uintptr_t) <base address expression>. */ ! seq = NULL; t = fold_convert_loc (location, mf_uintptr_type, unshare_expr (base)); t = force_gimple_operand (t, &stmts, false, NULL_TREE); *************** mf_build_check_statement_for (tree base, *** 683,689 **** This is the body of the conditional. */ ! seq = gimple_seq_alloc (); /* u is a string, so it is already a gimple value. */ u = mf_file_function_line_tree (location); /* NB: we pass the overall [base..limit] range to mf_check. */ --- 683,689 ---- This is the body of the conditional. */ ! seq = NULL; /* u is a string, so it is already a gimple value. */ u = mf_file_function_line_tree (location); /* NB: we pass the overall [base..limit] range to mf_check. */ *************** mf_build_check_statement_for (tree base, *** 704,710 **** gsi_insert_seq_after (&gsi, seq, GSI_CONTINUE_LINKING); e = split_block (then_bb, g); then_bb = e->dest; ! seq = gimple_seq_alloc (); } g = gimple_build_assign (mf_cache_shift_decl_l, mf_cache_shift_decl); --- 704,710 ---- gsi_insert_seq_after (&gsi, seq, GSI_CONTINUE_LINKING); e = split_block (then_bb, g); then_bb = e->dest; ! seq = NULL; } g = gimple_build_assign (mf_cache_shift_decl_l, mf_cache_shift_decl); *************** mx_register_decls (tree decl, gimple_seq *** 1114,1120 **** if (finally_stmts != NULL) { gimple stmt = gimple_build_try (seq, finally_stmts, GIMPLE_TRY_FINALLY); ! gimple_seq new_seq = gimple_seq_alloc (); gimple_seq_add_stmt (&new_seq, stmt); return new_seq; --- 1114,1120 ---- if (finally_stmts != NULL) { gimple stmt = gimple_build_try (seq, finally_stmts, GIMPLE_TRY_FINALLY); ! gimple_seq new_seq = NULL; gimple_seq_add_stmt (&new_seq, stmt); return new_seq;