This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tuples] Fix walk_gimple_omp_for
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Aldy Hernandez <aldyh at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 30 May 2008 07:04:14 -0400
- Subject: [tuples] Fix walk_gimple_omp_for
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
lower_nested_functions is done with cfun NULL, unfortunately gsi_remove
walk_gimple_omp_for was using as a hack relies on cfun in several places.
This patch avoids the creation of the dummy GIMPLE_NOP.
Ok for tuples?
2008-05-30 Jakub Jelinek <jakub@redhat.com>
* tree-nested.c (init_tmp_var_with_call, init_tmp_var, save_tmp_var):
Only set location if not gsi_end_p.
(walk_gimple_omp_for): Avoid adding an empty statement to seq.
--- gcc/tree-nested.c.jj 2008-05-28 09:17:31.000000000 +0200
+++ gcc/tree-nested.c 2008-05-30 11:46:23.000000000 +0200
@@ -366,7 +366,8 @@ init_tmp_var_with_call (struct nesting_i
t = create_tmp_var_for (info, TREE_TYPE (TREE_TYPE (gimple_call_fn (call))),
NULL);
gimple_call_set_lhs (call, t);
- gimple_set_location (call, gimple_location (gsi_stmt (*gsi)));
+ if (! gsi_end_p (*gsi))
+ gimple_set_location (call, gimple_location (gsi_stmt (*gsi)));
gsi_insert_before (gsi, call, GSI_SAME_STMT);
return t;
@@ -384,7 +385,8 @@ init_tmp_var (struct nesting_info *info,
t = create_tmp_var_for (info, TREE_TYPE (exp), NULL);
stmt = gimple_build_assign (t, exp);
- gimple_set_location (stmt, gimple_location (gsi_stmt (*gsi)));
+ if (! gsi_end_p (*gsi))
+ gimple_set_location (stmt, gimple_location (gsi_stmt (*gsi)));
gsi_insert_before_without_update (gsi, stmt, GSI_SAME_STMT);
return t;
@@ -414,7 +416,8 @@ save_tmp_var (struct nesting_info *info,
t = create_tmp_var_for (info, TREE_TYPE (exp), NULL);
stmt = gimple_build_assign (exp, t);
- gimple_set_location (stmt, gimple_location (gsi_stmt (*gsi)));
+ if (! gsi_end_p (*gsi))
+ gimple_set_location (stmt, gimple_location (gsi_stmt (*gsi)));
gsi_insert_after_without_update (gsi, stmt, GSI_SAME_STMT);
return t;
@@ -567,19 +570,15 @@ walk_gimple_omp_for (gimple for_stmt,
{
struct walk_stmt_info wi;
gimple_seq seq;
- gimple empty;
tree t;
walk_body (callback_stmt, callback_op, info, gimple_omp_for_pre_body (for_stmt));
- empty = gimple_build_nop ();
- seq = NULL;
- gimple_seq_add_stmt (&seq, empty);
+ seq = gimple_seq_alloc ();
memset (&wi, 0, sizeof (wi));
wi.info = info;
wi.gsi = gsi_last (seq);
- gimple_set_location (empty, gimple_location (for_stmt));
wi.val_only = false;
walk_tree (gimple_omp_for_index_ptr (for_stmt), callback_op, &wi, NULL);
wi.val_only = true;
@@ -589,10 +588,10 @@ walk_gimple_omp_for (gimple for_stmt,
wi.val_only = true;
wi.is_lhs = false;
walk_tree (gimple_omp_for_final_ptr (for_stmt), callback_op, &wi, NULL);
+ annotate_all_with_location (seq, gimple_location (for_stmt));
t = gimple_omp_for_incr (for_stmt);
gcc_assert (TREE_CODE (t) == GIMPLE_MODIFY_STMT);
- gimple_set_location (empty, *EXPR_LOCUS (gimple_omp_for_incr (for_stmt)));
wi.val_only = false;
walk_tree (&GIMPLE_STMT_OPERAND (t, 0), callback_op, &wi, NULL);
t = GIMPLE_STMT_OPERAND (t, 1);
@@ -602,14 +601,17 @@ walk_gimple_omp_for (gimple for_stmt,
wi.val_only = true;
wi.is_lhs = false;
walk_tree (&TREE_OPERAND (t, 1), callback_op, &wi, NULL);
+ annotate_all_with_location (seq,
+ *EXPR_LOCUS (gimple_omp_for_incr (for_stmt)));
- /* Remove empty statement added above from the end of statement list. */
- gsi_remove (&wi.gsi, true);
- {
- gimple_seq pre_body = gimple_omp_for_pre_body (for_stmt);
- gimple_seq_add_seq (&pre_body, seq);
- gimple_omp_for_set_pre_body (for_stmt, pre_body);
- }
+ if (gimple_seq_empty_p (seq))
+ gimple_seq_free (seq);
+ else
+ {
+ gimple_seq pre_body = gimple_omp_for_pre_body (for_stmt);
+ gimple_seq_add_seq (&pre_body, seq);
+ gimple_omp_for_set_pre_body (for_stmt, pre_body);
+ }
}
/* Similarly for ROOT and all functions nested underneath, depth first. */
Jakub