diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-01-25 12:54:42 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-01-25 12:54:42 +0000 |
commit | b43fc0dc6333c862d43f9db0e51334ac53007d81 (patch) | |
tree | 9a5c3be70549d48c772a09123c8b458d609517b3 /gcc/tree-nested.c | |
parent | 8090c12d167f85ca166f65c3f49f8818ebd42e5f (diff) | |
download | gcc-b43fc0dc6333c862d43f9db0e51334ac53007d81.tar.gz |
PR middle-end/33880
* tree-nested.c (walk_omp_for): New function.
(convert_nonlocal_reference, convert_local_reference): Call
walk_omp_for on OMP_FOR.
(convert_call_expr): Call walk_body on OMP_FOR's
OMP_FOR_PRE_INIT_BODY.
* testsuite/libgomp.c/pr33880.c: New test.
* testsuite/libgomp.fortran/pr33880.f90: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@131825 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-nested.c')
-rw-r--r-- | gcc/tree-nested.c | 71 |
1 files changed, 70 insertions, 1 deletions
diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c index 118f5fe4569..08f3eb1b491 100644 --- a/gcc/tree-nested.c +++ b/gcc/tree-nested.c @@ -1,5 +1,5 @@ /* Nested function decomposition for trees. - Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. This file is part of GCC. @@ -665,6 +665,59 @@ walk_function (walk_tree_fn callback, struct nesting_info *info) walk_body (callback, info, &DECL_SAVED_TREE (info->context)); } +/* Invoke CALLBACK on OMP_FOR init, cond, incr and pre-body. */ + +static void +walk_omp_for (walk_tree_fn callback, struct nesting_info *info, tree for_stmt) +{ + struct walk_stmt_info wi; + tree t, list = NULL, empty; + + walk_body (callback, info, &OMP_FOR_PRE_BODY (for_stmt)); + + empty = build_empty_stmt (); + append_to_statement_list_force (empty, &list); + memset (&wi, 0, sizeof (wi)); + wi.callback = callback; + wi.info = info; + wi.tsi = tsi_last (list); + + t = OMP_FOR_INIT (for_stmt); + gcc_assert (TREE_CODE (t) == GIMPLE_MODIFY_STMT); + SET_EXPR_LOCUS (empty, EXPR_LOCUS (t)); + wi.val_only = false; + walk_tree (&GIMPLE_STMT_OPERAND (t, 0), callback, &wi, NULL); + wi.val_only = true; + wi.is_lhs = false; + walk_tree (&GIMPLE_STMT_OPERAND (t, 1), callback, &wi, NULL); + + t = OMP_FOR_COND (for_stmt); + gcc_assert (COMPARISON_CLASS_P (t)); + SET_EXPR_LOCUS (empty, EXPR_LOCUS (t)); + wi.val_only = false; + walk_tree (&TREE_OPERAND (t, 0), callback, &wi, NULL); + wi.val_only = true; + wi.is_lhs = false; + walk_tree (&TREE_OPERAND (t, 1), callback, &wi, NULL); + + t = OMP_FOR_INCR (for_stmt); + gcc_assert (TREE_CODE (t) == GIMPLE_MODIFY_STMT); + SET_EXPR_LOCUS (empty, EXPR_LOCUS (t)); + wi.val_only = false; + walk_tree (&GIMPLE_STMT_OPERAND (t, 0), callback, &wi, NULL); + t = GIMPLE_STMT_OPERAND (t, 1); + gcc_assert (BINARY_CLASS_P (t)); + wi.val_only = false; + walk_tree (&TREE_OPERAND (t, 0), callback, &wi, NULL); + wi.val_only = true; + wi.is_lhs = false; + walk_tree (&TREE_OPERAND (t, 1), callback, &wi, NULL); + + /* Remove empty statement added above from the end of statement list. */ + tsi_delink (&wi.tsi); + append_to_statement_list (list, &OMP_FOR_PRE_BODY (for_stmt)); +} + /* Similarly for ROOT and all functions nested underneath, depth first. */ static void @@ -1065,6 +1118,13 @@ convert_nonlocal_reference (tree *tp, int *walk_subtrees, void *data) break; case OMP_FOR: + save_suppress = info->suppress_expansion; + convert_nonlocal_omp_clauses (&OMP_FOR_CLAUSES (t), wi); + walk_omp_for (convert_nonlocal_reference, info, t); + walk_body (convert_nonlocal_reference, info, &OMP_FOR_BODY (t)); + info->suppress_expansion = save_suppress; + break; + case OMP_SECTIONS: case OMP_SINGLE: save_suppress = info->suppress_expansion; @@ -1350,6 +1410,13 @@ convert_local_reference (tree *tp, int *walk_subtrees, void *data) break; case OMP_FOR: + save_suppress = info->suppress_expansion; + convert_local_omp_clauses (&OMP_FOR_CLAUSES (t), wi); + walk_omp_for (convert_local_reference, info, t); + walk_body (convert_local_reference, info, &OMP_FOR_BODY (t)); + info->suppress_expansion = save_suppress; + break; + case OMP_SECTIONS: case OMP_SINGLE: save_suppress = info->suppress_expansion; @@ -1682,6 +1749,8 @@ convert_call_expr (tree *tp, int *walk_subtrees, void *data) break; case OMP_FOR: + walk_body (convert_call_expr, info, &OMP_FOR_PRE_BODY (t)); + /* FALLTHRU */ case OMP_SECTIONS: case OMP_SECTION: case OMP_SINGLE: |