On 01/06/2016 07:55 PM, Cesar Philippidis wrote: > @@ -1384,26 +1331,9 @@ build_outer_var_ref (tree var, omp_context *ctx, bool > lastprivate = false) > x = build_simple_mem_ref (x); > } > } > - else if (is_oacc_parallel (ctx)) > - x = var; > else if (ctx->outer) > - { > - /* OpenACC may have multiple outer contexts (one per loop). */ > - if (gimple_code (ctx->stmt) == GIMPLE_OMP_FOR > - && gimple_omp_for_kind (ctx->stmt) == GF_OMP_FOR_KIND_OACC_LOOP) > - { > - do > - { > - ctx = ctx->outer; > - x = maybe_lookup_decl (var, ctx); > - } > - while(!x); > - } > - else > - x = lookup_decl (var, ctx->outer); > - }
It turns out that this is still necessary for openacc. The attached patch reverts this particular change. This fixes a bug that I encountered in a program I which I didn't have time to reduce. Basically, that program was doing something like this #pragma acc loop vector(length:var) where var is some variable declared outside of a kernels region. I'll apply the patch to gomp4 now, and add a couple of more test cases next week. Cesar
2016-01-08 Cesar Philippidis <ce...@codesourcery.com> gcc/ * omp-low.c (build_outer_var_ref): Recursively scan for decls in outer omp contexts. diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 69dabfe..98422fb 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -1332,7 +1332,21 @@ build_outer_var_ref (tree var, omp_context *ctx, bool lastprivate = false) } } else if (ctx->outer) - x = lookup_decl (var, ctx->outer); + { + /* OpenACC may have multiple outer contexts (one per loop). */ + if (gimple_code (ctx->stmt) == GIMPLE_OMP_FOR + && gimple_omp_for_kind (ctx->stmt) == GF_OMP_FOR_KIND_OACC_LOOP) + { + do + { + ctx = ctx->outer; + x = maybe_lookup_decl (var, ctx); + } + while(!x); + } + else + x = lookup_decl (var, ctx->outer); + } else if (is_reference (var)) /* This can happen with orphaned constructs. If var is reference, it is possible it is shared and as such valid. */