diff options
author | Martin Jambor <mjambor@suse.cz> | 2015-12-10 16:40:57 +0100 |
---|---|---|
committer | Martin Jambor <jamborm@gcc.gnu.org> | 2015-12-10 16:40:57 +0100 |
commit | f680334141b73d2ceb1baf38a56dcca5985a960a (patch) | |
tree | 93a7daadfce29d70f2a63ab6d44abeb0514484a0 /gcc/tree-inline.c | |
parent | 4c1ca083ca75d75ca6d2746a6fd43bfa2d9a7b0a (diff) | |
download | gcc-f680334141b73d2ceb1baf38a56dcca5985a960a.zip gcc-f680334141b73d2ceb1baf38a56dcca5985a960a.tar.gz gcc-f680334141b73d2ceb1baf38a56dcca5985a960a.tar.bz2 |
tree-inline.c (duplicate_remap_omp_clause_seq): New function.
2015-12-10 Martin Jambor <mjambor@suse.cz>
* tree-inline.c (duplicate_remap_omp_clause_seq): New function.
(replace_locals_op): Duplicate gimple sequences in OMP clauses.
From-SVN: r231523
Diffstat (limited to 'gcc/tree-inline.c')
-rw-r--r-- | gcc/tree-inline.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index ebab189..dea23c7 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -5116,6 +5116,8 @@ mark_local_labels_stmt (gimple_stmt_iterator *gsip, return NULL_TREE; } +static gimple_seq duplicate_remap_omp_clause_seq (gimple_seq seq, + struct walk_stmt_info *wi); /* Called via walk_gimple_seq by copy_gimple_seq_and_replace_local. Using the splay_tree pointed to by ST (which is really a `splay_tree'), @@ -5160,6 +5162,35 @@ replace_locals_op (tree *tp, int *walk_subtrees, void *data) TREE_OPERAND (expr, 3) = NULL_TREE; } } + else if (TREE_CODE (expr) == OMP_CLAUSE) + { + /* Before the omplower pass completes, some OMP clauses can contain + sequences that are neither copied by gimple_seq_copy nor walked by + walk_gimple_seq. To make copy_gimple_seq_and_replace_locals work even + in those situations, we have to copy and process them explicitely. */ + + if (OMP_CLAUSE_CODE (expr) == OMP_CLAUSE_LASTPRIVATE) + { + gimple_seq seq = OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (expr); + seq = duplicate_remap_omp_clause_seq (seq, wi); + OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (expr) = seq; + } + else if (OMP_CLAUSE_CODE (expr) == OMP_CLAUSE_LINEAR) + { + gimple_seq seq = OMP_CLAUSE_LINEAR_GIMPLE_SEQ (expr); + seq = duplicate_remap_omp_clause_seq (seq, wi); + OMP_CLAUSE_LINEAR_GIMPLE_SEQ (expr) = seq; + } + else if (OMP_CLAUSE_CODE (expr) == OMP_CLAUSE_REDUCTION) + { + gimple_seq seq = OMP_CLAUSE_REDUCTION_GIMPLE_INIT (expr); + seq = duplicate_remap_omp_clause_seq (seq, wi); + OMP_CLAUSE_REDUCTION_GIMPLE_INIT (expr) = seq; + seq = OMP_CLAUSE_REDUCTION_GIMPLE_MERGE (expr); + seq = duplicate_remap_omp_clause_seq (seq, wi); + OMP_CLAUSE_REDUCTION_GIMPLE_MERGE (expr) = seq; + } + } /* Keep iterating. */ return NULL_TREE; @@ -5200,6 +5231,21 @@ replace_locals_stmt (gimple_stmt_iterator *gsip, return NULL_TREE; } +/* Create a copy of SEQ and remap all decls in it. */ + +static gimple_seq +duplicate_remap_omp_clause_seq (gimple_seq seq, struct walk_stmt_info *wi) +{ + if (!seq) + return NULL; + + /* If there are any labels in OMP sequences, they can be only referred to in + the sequence itself and therefore we can do both here. */ + walk_gimple_seq (seq, mark_local_labels_stmt, NULL, wi); + gimple_seq copy = gimple_seq_copy (seq); + walk_gimple_seq (copy, replace_locals_stmt, replace_locals_op, wi); + return copy; +} /* Copies everything in SEQ and replaces variables and labels local to current_function_decl. */ |