diff options
author | matz <matz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-05-02 16:41:48 +0000 |
---|---|---|
committer | matz <matz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-05-02 16:41:48 +0000 |
commit | e3a19533c3ba16854e1dc1bb2ac7ce197883e38f (patch) | |
tree | a909112c3b26051d56924ebe9435b84f207b2091 /gcc/gimple.c | |
parent | 93106215b9a003a0f5aa582d4c2b9078cb386d47 (diff) | |
download | gcc-e3a19533c3ba16854e1dc1bb2ac7ce197883e38f.tar.gz |
* coretypes.h (gimple_seq, const_gimple_seq): Typedef as gimple.
* gimple.h (struct gimple_seq_node_d, struct gimple_seq_d): Remove.
(const_gimple_seq_node): Remove.
(gimple_seq_node): Typedef as gimple.
(struct gimple_statement_base): Add next and prev members,
adjust all WORD markers in using structs.
(union gimple_statement_d): Link via gsbase.next field for GC and PCH.
(gimple_seq_first, gimple_seq_first_stmt, gimple_seq_last,
gimple_seq_last_stmt): Adjust as gimple_seq, gimple_seq_node and
gimple are the same.
(gimple_seq_set_last, gimple_seq_set_first): Don't allocate
gimple_seq, adjust.
(gimple_init_singleton): New function.
(gsi_start_1, gsi_last_1, gsi_end_p, gsi_one_before_end_p): Adjust.
(gsi_next, gsi_prev): Adjust, handle prev cyclic list correctly.
(gsi_stmt): Adjust.
(gsi_stmt_ptr): Remove.
(enum gimple_alloc_kind): Remove gimple_alloc_kind_seq member.
* gimple-iterator.c (update_bb_for_stmts): Take last parameter
again, adjust for above changes.
(update_call_edge_frequencies): Adjust for above changes.
(gsi_insert_seq_nodes_before): Rewrite for new data structure.
(gsi_insert_seq_nodes_after): Ditto.
(gsi_split_seq_after): Ditto.
(gsi_set_stmt): Ditto.
(gsi_split_seq_before): Ditto.
(gsi_remove): Ditto.
(gsi_insert_seq_before_without_update): Don't free sequence.
(gsi_insert_seq_after_without_update): Ditto.
(gsi_replace): Assert some more invariants.
(gsi_insert_before_without_update, gsi_insert_after_without_update):
Tidy.
(gsi_for_stmt): Don't search for stmt.
(gsi_insert_on_edge_immediate): Tidy.
* gimple.c (gimple_alloc_k): Remove "sequences".
(gimple_seq_cache): Remove.
(gimple_alloc_stat): Make stmt a singleton sequence.
(gimple_seq_alloc, gimple_seq_free): Remove.
(gimple_assign_set_rhs_with_ops_1): Ensure new stmt is a singleton.
(gimple_copy): Ditto.
* gimplify.c (gimplify_cleanup_point_expr): Use gsi_set_stmt,
create iterator from correct sequence.
* tree-phinodes.c (make_phi_node): Make stmt a singleton.
* gimple.h (gimple_stmt_iterator <seq>): Make it be pointer to
gimple_seq.
(gimple_seq_set_last, gimple_seq_set_first): Take pointer to
sequence, lazily allocate it.
(bb_seq_addr): New function.
(gsi_start_1): Rename from gsi_start, but take pointer to sequence.
(gsi_start): Macro to wrap gsi_start_1 taking pointer of argument.
(gsi_none): New function.
(gsi_start_bb): Adjust.
(gsi_last_1): Rename from gsi_last, but take pointer to sequence.
(gsi_last): Macro to wrap gsi_last_1 taking pointer of argument.
(gsi_last_bb): Adjust.
(gsi_seq): Adjust.
* tree-flow-inline.h (phi_nodes_ptr): New function.
* gimple-iterator.c (gsi_insert_seq_nodes_before): Adjust to
datastructure and interface change.
(gsi_insert_seq_before_without_update): Ditto.
(gsi_insert_seq_nodes_after): Ditto.
(gsi_insert_seq_after_without_update): Ditto.
(gsi_split_seq_after): Ditto, don't use gimple_seq_alloc.
(gsi_split_seq_before): Ditto.
(gsi_start_phis): Adjust.
* tree-vect-loop.c (vect_determine_vectorization_factor): Use
gsi_none.
(vect_transform_loop): Ditto.
* gimple.c (gimple_seq_add_stmt, gimple_seq_add_seq,
gimple_seq_copy): Don't use gimple_seq_alloc.
* gimplify.c (gimple_seq_add_stmt_without_update): Ditto.
(gimplify_seq_add_seq): Ditto.
* lto-streamer-in.c (make_new_block): Ditto.
* tree-cfg.c (create_bb): Ditto.
* tree-sra.c (initialize_parameter_reductions): Ditto.
* gimple.h (gimple_seq_first, gimple_seq_first_stmt, gimple_seq_last,
gimple_seq_last_stmt, gimple_seq_set_last, gimple_seq_set_first,
gimple_seq_empty_p, gimple_seq_alloc_with_stmt, bb_seq,
set_bb_seq): Move down to after gimple_statement_d definition.
* gimple-fold.c (gimplify_and_update_call_from_tree): Use
gsi_replace_with_seq, instead of inserting itself.
* gimple-iterator.c (gsi_replace_with_seq): New function.
* tree-ssa-forwprop.c (forward_propagate_comparison): Take
iterator instead of statement, advance it.
(ssa_forward_propagate_and_combine): Adjust call to above.
* 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.
* gimple.h (gimple_bind_body_ptr): New function.
(gimple_bind_body): Use it.
(gimple_catch_handler): Use gimple_catch_handler_ptr.
(gimple_eh_filter_failure_ptr): New function.
(gimple_eh_filter_failure): Use it.
(gimple_eh_else_n_body_ptr): New function.
(gimple_eh_else_n_body): Use it.
(gimple_eh_else_e_body_ptr): New function.
(gimple_eh_else_e_body): Use it.
(gimple_try_eval_ptr): New function.
(gimple_try_eval): Use it.
(gimple_try_cleanup_ptr): New function.
(gimple_try_cleanup): Use it.
(gimple_wce_cleanup_ptr): New function.
(gimple_wce_cleanup): Use it.
(gimple_omp_body_ptr): New function.
(gimple_omp_body): Use it.
(gimple_omp_for_pre_body_ptr): New function.
(gimple_omp_for_pre_body): Use it.
(gimple_transaction_body_ptr): New function.
(gimple_transaction_body): Use it.
(gsi_split_seq_before): Adjust to return nothing and take pointer
to sequence.
(gsi_set_stmt): Declare.
(gsi_replace_with_seq): Declare.
(walk_gimple_seq_mod): Declare.
* function.h (struct function <gimple_body>): Use typedef gimple_seq.
* gimple-iterator.c (gsi_set_stmt): New function.
(gsi_split_seq_before): Return new sequence via pointer argument.
(gsi_replace): Use gsi_set_stmt.
* tree-ssa-loop-im.c (move_computations_stmt): First remove
then insert stmt.
* tree-complex.c (update_complex_components_on_edge): Don't
copy gsi.
* tree-phinodes.c (resize_phi_node): Don't resize stmt in-place,
return new stmt.
(reserve_phi_args_for_new_edge): Change call to above,
use gsi_set_stmt.
* omp-low.c (lower_omp): Change prototype to take pointer to
sequence.
(lower_rec_input_clauses): Use gimple_seq_add_seq instead of
iterators. Adjust call to lower_omp.
(lower_lastprivate_clauses): Adjust call to lower_omp.
(lower_reduction_clauses): Ditto.
(expand_omp_taskreg): Nullify non-cfg body of child_fn.
(lower_omp_sections): Don't explicitely count sequence length,
nullify lowered bodies earlier, ensure stmts are part of only
one sequence, adjust call to lower_omp.
(lower_omp_single): Ensure stmts are part of only one sequence,
adjust call to lower_omp.
(lower_omp_master): Ditto.
(lower_omp_ordered): Ditto.
(lower_omp_critical): Ditto.
(lower_omp_for): Ditto.
(lower_omp_taskreg): Ditto, tidy.
(lower_omp_1): Adjust calls to lower_omp.
(execute_lower_omp): Ditto.
(lower_omp): Adjust to take pointer to sequence.
(diagnose_sb_2): Use walk_gimple_seq_mod.
(diagnose_omp_structured_block_errors): Ditto and set possibly
changed function body.
* gimple-low.c (lower_function_body): Set function body after
it stabilizes.
(lower_sequence): Adjust to take pointer to sequence.
(lower_omp_directive): Ensure stmt isn't put twice into the
sequence, adjust call to lower_sequence.
(lower_stmt): Adjust calls to lower_sequence.
(lower_gimple_bind): Ditto.
(gimple_try_catch_may_fallthru): Call gsi_start with lvalue.
* tree-nested.c (walk_body): Take pointer to sequence, use
walk_gimple_seq_mod.
(walk_function): Adjust call to walk_body, set possibly changed
body.
(walk_gimple_omp_for): Adjust calls to walk_body.
(convert_nonlocal_omp_clauses): Ditto.
(convert_nonlocal_reference_stmt): Ditto.
(convert_local_omp_clauses): Ditto.
(convert_local_reference_stmt): Ditto.
(convert_tramp_reference_stmt): Ditto.
(convert_gimple_call): Ditto.
(convert_nl_goto_reference): Use local iterator copy.
* gimple.c (walk_gimple_seq_mod): Renamed from walk_gimple_seq,
but taking pointer to sequence, ensure gsi_start is called with
callers lvalue.
(walk_gimple_seq): New wrapper around walk_gimple_seq_mod,
asserting that the sequence head didn't change.
(walk_gimple_stmt): Replace all calls to walk_gimple_seq with
walk_gimple_seq_mod.
* trans-mem.c (lower_transaction): Use walk_gimple_seq_mod.
(execute_lower_tm): Ditto, and set possibly changed body.
* tree-eh.c (lower_eh_constructs_1): Take pointer to sequence,
call gsi_start with that lvalue.
(replace_goto_queue_stmt_list): Ditto.
(replace_goto_queue_1): Adjust calls to replace_goto_queue_stmt_list.
(replace_goto_queue): Ditto.
(lower_try_finally_nofallthru): Adjust calls to lower_eh_constructs_1.
(lower_try_finally_onedest): Ditto.
(lower_try_finally_copy): Ditto.
(lower_try_finally_switch): Ditto.
(lower_try_finally): Ditto.
(lower_eh_filter): Ditto.
(lower_eh_must_not_throw): Ditto.
(lower_cleanup): Ditto.
(lower_eh_constructs_2): Ditto.
(lower_catch): Ditto, and ensure gsi_start is called with lvalue.
(lower_eh_constructs): Adjust calls to lower_eh_constructs_1, and
set possibly changed body.
(optimize_double_finally): Call gsi_start with lvalue.
* tree-cfg.c (make_blocks): Adjust call to gsi_split_seq_before.
(gimple_split_block): Ditto.
(gimple_merge_blocks): Use gsi_start_phis.
(move_stmt_r): Use walk_gimple_seq_mod.
* tree-ssa-dse.c (dse_enter_block): Use gsi_last_bb.
* cgraphbuild.c (build_cgraph_edges): Use gsi_start_phis.
(rebuild_cgraph_edges): Ditto.
(cgraph_rebuild_references): Ditto.
* ipa-prop.c (ipa_analyze_params_uses): Ditto.
* tree-inline.c (copy_phis_for_bb): Ditto.
* tree-ssa-dce.c: Ditto.
* cgraphunit.c (cgraph_analyze_function): Use gimple_has_body_p.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@187053 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gimple.c')
-rw-r--r-- | gcc/gimple.c | 116 |
1 files changed, 37 insertions, 79 deletions
diff --git a/gcc/gimple.c b/gcc/gimple.c index 95d79dc1e02..e8841ec65ae 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -90,16 +90,11 @@ static const char * const gimple_alloc_kind_names[] = { "assignments", "phi nodes", "conditionals", - "sequences", "everything else" }; #endif /* GATHER_STATISTICS */ -/* A cache of gimple_seq objects. Sequences are created and destroyed - fairly often during gimplification. */ -static GTY ((deletable)) struct gimple_seq_d *gimple_seq_cache; - /* Private API manipulation functions shared only with some other files. */ extern void gimple_set_stored_syms (gimple, bitmap, bitmap_obstack *); @@ -154,6 +149,7 @@ gimple_alloc_stat (enum gimple_code code, unsigned num_ops MEM_STAT_DECL) /* Do not call gimple_set_modified here as it has other side effects and this tuple is still not completely built. */ stmt->gsbase.modified = 1; + gimple_init_singleton (stmt); return stmt; } @@ -1201,53 +1197,6 @@ gimple_check_failed (const_gimple gs, const char *file, int line, #endif /* ENABLE_GIMPLE_CHECKING */ -/* Allocate a new GIMPLE sequence in GC memory and return it. If - there are free sequences in GIMPLE_SEQ_CACHE return one of those - instead. */ - -gimple_seq -gimple_seq_alloc (void) -{ - gimple_seq seq = gimple_seq_cache; - if (seq) - { - gimple_seq_cache = gimple_seq_cache->next_free; - gcc_assert (gimple_seq_cache != seq); - memset (seq, 0, sizeof (*seq)); - } - else - { - seq = ggc_alloc_cleared_gimple_seq_d (); -#ifdef GATHER_STATISTICS - gimple_alloc_counts[(int) gimple_alloc_kind_seq]++; - gimple_alloc_sizes[(int) gimple_alloc_kind_seq] += sizeof (*seq); -#endif - } - - return seq; -} - -/* Return SEQ to the free pool of GIMPLE sequences. */ - -void -gimple_seq_free (gimple_seq seq) -{ - if (seq == NULL) - return; - - gcc_assert (gimple_seq_first (seq) == NULL); - gcc_assert (gimple_seq_last (seq) == NULL); - - /* If this triggers, it's a sign that the same list is being freed - twice. */ - gcc_assert (seq != gimple_seq_cache || gimple_seq_cache == NULL); - - /* Add SEQ to the pool of free sequences. */ - seq->next_free = gimple_seq_cache; - gimple_seq_cache = seq; -} - - /* Link gimple statement GS to the end of the sequence *SEQ_P. If *SEQ_P is NULL, a new sequence is allocated. */ @@ -1255,13 +1204,9 @@ void gimple_seq_add_stmt (gimple_seq *seq_p, gimple gs) { gimple_stmt_iterator si; - if (gs == NULL) return; - if (*seq_p == NULL) - *seq_p = gimple_seq_alloc (); - si = gsi_last (*seq_p); gsi_insert_after (&si, gs, GSI_NEW_STMT); } @@ -1274,13 +1219,9 @@ void gimple_seq_add_seq (gimple_seq *dst_p, gimple_seq src) { gimple_stmt_iterator si; - if (src == NULL) return; - if (*dst_p == NULL) - *dst_p = gimple_seq_alloc (); - si = gsi_last (*dst_p); gsi_insert_seq_after (&si, src, GSI_NEW_STMT); } @@ -1324,7 +1265,7 @@ gimple_seq gimple_seq_copy (gimple_seq src) { gimple_stmt_iterator gsi; - gimple_seq new_seq = gimple_seq_alloc (); + gimple_seq new_seq = NULL; gimple stmt; for (gsi = gsi_start (src); !gsi_end_p (gsi); gsi_next (&gsi)) @@ -1337,7 +1278,7 @@ gimple_seq_copy (gimple_seq src) } -/* Walk all the statements in the sequence SEQ calling walk_gimple_stmt +/* Walk all the statements in the sequence *PSEQ calling walk_gimple_stmt on each one. WI is as in walk_gimple_stmt. If walk_gimple_stmt returns non-NULL, the walk is stopped, and the @@ -1349,12 +1290,12 @@ gimple_seq_copy (gimple_seq src) Otherwise, all the statements are walked and NULL returned. */ gimple -walk_gimple_seq (gimple_seq seq, walk_stmt_fn callback_stmt, - walk_tree_fn callback_op, struct walk_stmt_info *wi) +walk_gimple_seq_mod (gimple_seq *pseq, walk_stmt_fn callback_stmt, + walk_tree_fn callback_op, struct walk_stmt_info *wi) { gimple_stmt_iterator gsi; - for (gsi = gsi_start (seq); !gsi_end_p (gsi); ) + for (gsi = gsi_start (*pseq); !gsi_end_p (gsi); ) { tree ret = walk_gimple_stmt (&gsi, callback_stmt, callback_op, wi); if (ret) @@ -1378,6 +1319,20 @@ walk_gimple_seq (gimple_seq seq, walk_stmt_fn callback_stmt, } +/* Like walk_gimple_seq_mod, but ensure that the head of SEQ isn't + changed by the callbacks. */ + +gimple +walk_gimple_seq (gimple_seq seq, walk_stmt_fn callback_stmt, + walk_tree_fn callback_op, struct walk_stmt_info *wi) +{ + gimple_seq seq2 = seq; + gimple ret = walk_gimple_seq_mod (&seq2, callback_stmt, callback_op, wi); + gcc_assert (seq2 == seq); + return ret; +} + + /* Helper function for walk_gimple_stmt. Walk operands of a GIMPLE_ASM. */ static tree @@ -1808,51 +1763,51 @@ walk_gimple_stmt (gimple_stmt_iterator *gsi, walk_stmt_fn callback_stmt, switch (gimple_code (stmt)) { case GIMPLE_BIND: - ret = walk_gimple_seq (gimple_bind_body (stmt), callback_stmt, - callback_op, wi); + ret = walk_gimple_seq_mod (gimple_bind_body_ptr (stmt), callback_stmt, + callback_op, wi); if (ret) return wi->callback_result; break; case GIMPLE_CATCH: - ret = walk_gimple_seq (gimple_catch_handler (stmt), callback_stmt, - callback_op, wi); + ret = walk_gimple_seq_mod (gimple_catch_handler_ptr (stmt), callback_stmt, + callback_op, wi); if (ret) return wi->callback_result; break; case GIMPLE_EH_FILTER: - ret = walk_gimple_seq (gimple_eh_filter_failure (stmt), callback_stmt, + ret = walk_gimple_seq_mod (gimple_eh_filter_failure_ptr (stmt), callback_stmt, callback_op, wi); if (ret) return wi->callback_result; break; case GIMPLE_EH_ELSE: - ret = walk_gimple_seq (gimple_eh_else_n_body (stmt), + ret = walk_gimple_seq_mod (gimple_eh_else_n_body_ptr (stmt), callback_stmt, callback_op, wi); if (ret) return wi->callback_result; - ret = walk_gimple_seq (gimple_eh_else_e_body (stmt), + ret = walk_gimple_seq_mod (gimple_eh_else_e_body_ptr (stmt), callback_stmt, callback_op, wi); if (ret) return wi->callback_result; break; case GIMPLE_TRY: - ret = walk_gimple_seq (gimple_try_eval (stmt), callback_stmt, callback_op, + ret = walk_gimple_seq_mod (gimple_try_eval_ptr (stmt), callback_stmt, callback_op, wi); if (ret) return wi->callback_result; - ret = walk_gimple_seq (gimple_try_cleanup (stmt), callback_stmt, + ret = walk_gimple_seq_mod (gimple_try_cleanup_ptr (stmt), callback_stmt, callback_op, wi); if (ret) return wi->callback_result; break; case GIMPLE_OMP_FOR: - ret = walk_gimple_seq (gimple_omp_for_pre_body (stmt), callback_stmt, + ret = walk_gimple_seq_mod (gimple_omp_for_pre_body_ptr (stmt), callback_stmt, callback_op, wi); if (ret) return wi->callback_result; @@ -1866,21 +1821,21 @@ walk_gimple_stmt (gimple_stmt_iterator *gsi, walk_stmt_fn callback_stmt, case GIMPLE_OMP_TASK: case GIMPLE_OMP_SECTIONS: case GIMPLE_OMP_SINGLE: - ret = walk_gimple_seq (gimple_omp_body (stmt), callback_stmt, + ret = walk_gimple_seq_mod (gimple_omp_body_ptr (stmt), callback_stmt, callback_op, wi); if (ret) return wi->callback_result; break; case GIMPLE_WITH_CLEANUP_EXPR: - ret = walk_gimple_seq (gimple_wce_cleanup (stmt), callback_stmt, + ret = walk_gimple_seq_mod (gimple_wce_cleanup_ptr (stmt), callback_stmt, callback_op, wi); if (ret) return wi->callback_result; break; case GIMPLE_TRANSACTION: - ret = walk_gimple_seq (gimple_transaction_body (stmt), + ret = walk_gimple_seq_mod (gimple_transaction_body_ptr (stmt), callback_stmt, callback_op, wi); if (ret) return wi->callback_result; @@ -2181,6 +2136,7 @@ gimple_assign_set_rhs_with_ops_1 (gimple_stmt_iterator *gsi, enum tree_code code tree lhs = gimple_assign_lhs (stmt); gimple new_stmt = gimple_alloc (gimple_code (stmt), new_rhs_ops + 1); memcpy (new_stmt, stmt, gimple_size (gimple_code (stmt))); + gimple_init_singleton (new_stmt); gsi_replace (gsi, new_stmt, true); stmt = new_stmt; @@ -2270,7 +2226,8 @@ gimple_replace_lhs (gimple stmt, tree nlhs) /* Return a deep copy of statement STMT. All the operands from STMT are reallocated and copied using unshare_expr. The DEF, USE, VDEF - and VUSE operand arrays are set to empty in the new copy. */ + and VUSE operand arrays are set to empty in the new copy. The new + copy isn't part of any sequence. */ gimple gimple_copy (gimple stmt) @@ -2282,6 +2239,7 @@ gimple_copy (gimple stmt) /* Shallow copy all the fields from STMT. */ memcpy (copy, stmt, gimple_size (code)); + gimple_init_singleton (copy); /* If STMT has sub-statements, deep-copy them as well. */ if (gimple_has_substatements (stmt)) |