diff options
Diffstat (limited to 'gcc/tree-nested.c')
-rw-r--r-- | gcc/tree-nested.c | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c index 2bb1106..6f696da 100644 --- a/gcc/tree-nested.c +++ b/gcc/tree-nested.c @@ -1188,7 +1188,7 @@ convert_nonlocal_omp_clauses (tree *pclauses, struct walk_stmt_info *wi) { struct nesting_info *const info = (struct nesting_info *) wi->info; bool need_chain = false, need_stmts = false; - tree clause, decl; + tree clause, decl, *pdecl; int dummy; bitmap new_suppress; @@ -1197,6 +1197,7 @@ convert_nonlocal_omp_clauses (tree *pclauses, struct walk_stmt_info *wi) for (clause = *pclauses; clause ; clause = OMP_CLAUSE_CHAIN (clause)) { + pdecl = NULL; switch (OMP_CLAUSE_CODE (clause)) { case OMP_CLAUSE_REDUCTION: @@ -1204,6 +1205,15 @@ convert_nonlocal_omp_clauses (tree *pclauses, struct walk_stmt_info *wi) case OMP_CLAUSE_TASK_REDUCTION: if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (clause)) need_stmts = true; + if (TREE_CODE (OMP_CLAUSE_DECL (clause)) == MEM_REF) + { + pdecl = &TREE_OPERAND (OMP_CLAUSE_DECL (clause), 0); + if (TREE_CODE (*pdecl) == POINTER_PLUS_EXPR) + pdecl = &TREE_OPERAND (*pdecl, 0); + if (TREE_CODE (*pdecl) == INDIRECT_REF + || TREE_CODE (*pdecl) == ADDR_EXPR) + pdecl = &TREE_OPERAND (*pdecl, 0); + } goto do_decl_clause; case OMP_CLAUSE_LASTPRIVATE: @@ -1230,7 +1240,9 @@ convert_nonlocal_omp_clauses (tree *pclauses, struct walk_stmt_info *wi) case OMP_CLAUSE_USE_DEVICE_ADDR: case OMP_CLAUSE_IS_DEVICE_PTR: do_decl_clause: - decl = OMP_CLAUSE_DECL (clause); + if (pdecl == NULL) + pdecl = &OMP_CLAUSE_DECL (clause); + decl = *pdecl; if (VAR_P (decl) && (TREE_STATIC (decl) || DECL_EXTERNAL (decl))) break; @@ -1239,7 +1251,7 @@ convert_nonlocal_omp_clauses (tree *pclauses, struct walk_stmt_info *wi) if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_SHARED) OMP_CLAUSE_SHARED_READONLY (clause) = 0; bitmap_set_bit (new_suppress, DECL_UID (decl)); - OMP_CLAUSE_DECL (clause) = get_nonlocal_debug_decl (info, decl); + *pdecl = get_nonlocal_debug_decl (info, decl); if (OMP_CLAUSE_CODE (clause) != OMP_CLAUSE_PRIVATE) need_chain = true; } @@ -1909,7 +1921,7 @@ convert_local_omp_clauses (tree *pclauses, struct walk_stmt_info *wi) { struct nesting_info *const info = (struct nesting_info *) wi->info; bool need_frame = false, need_stmts = false; - tree clause, decl; + tree clause, decl, *pdecl; int dummy; bitmap new_suppress; @@ -1918,6 +1930,7 @@ convert_local_omp_clauses (tree *pclauses, struct walk_stmt_info *wi) for (clause = *pclauses; clause ; clause = OMP_CLAUSE_CHAIN (clause)) { + pdecl = NULL; switch (OMP_CLAUSE_CODE (clause)) { case OMP_CLAUSE_REDUCTION: @@ -1925,6 +1938,15 @@ convert_local_omp_clauses (tree *pclauses, struct walk_stmt_info *wi) case OMP_CLAUSE_TASK_REDUCTION: if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (clause)) need_stmts = true; + if (TREE_CODE (OMP_CLAUSE_DECL (clause)) == MEM_REF) + { + pdecl = &TREE_OPERAND (OMP_CLAUSE_DECL (clause), 0); + if (TREE_CODE (*pdecl) == POINTER_PLUS_EXPR) + pdecl = &TREE_OPERAND (*pdecl, 0); + if (TREE_CODE (*pdecl) == INDIRECT_REF + || TREE_CODE (*pdecl) == ADDR_EXPR) + pdecl = &TREE_OPERAND (*pdecl, 0); + } goto do_decl_clause; case OMP_CLAUSE_LASTPRIVATE: @@ -1951,7 +1973,9 @@ convert_local_omp_clauses (tree *pclauses, struct walk_stmt_info *wi) case OMP_CLAUSE_USE_DEVICE_ADDR: case OMP_CLAUSE_IS_DEVICE_PTR: do_decl_clause: - decl = OMP_CLAUSE_DECL (clause); + if (pdecl == NULL) + pdecl = &OMP_CLAUSE_DECL (clause); + decl = *pdecl; if (VAR_P (decl) && (TREE_STATIC (decl) || DECL_EXTERNAL (decl))) break; @@ -1964,8 +1988,7 @@ convert_local_omp_clauses (tree *pclauses, struct walk_stmt_info *wi) if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_SHARED) OMP_CLAUSE_SHARED_READONLY (clause) = 0; bitmap_set_bit (new_suppress, DECL_UID (decl)); - OMP_CLAUSE_DECL (clause) - = get_local_debug_decl (info, decl, field); + *pdecl = get_local_debug_decl (info, decl, field); need_frame = true; } } |