diff mbox

[hsa] Fix ICE in build_outer_var_ref within GPUKERNEL

Message ID 20151019101210.GE7998@virgil.suse.cz
State New
Headers show

Commit Message

Martin Jambor Oct. 19, 2015, 10:12 a.m. UTC
Hi,

the following patch fixes a segfault when building an outer_ref which
would be in GPUKERNEL context hwen lowering.  In that case, we need to
use the outer context od the GPUKERNEL container.  Committed to the
branch.

Thanks,

Martin


2015-10-19  Martin Jambor  <mjambor@suse.cz>

	* omp-low.c (build_outer_var_ref): If outer ctx is GPUKERNEL, use its
	outer ctx.
diff mbox

Patch

diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 383f34a..5234a11 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -1186,7 +1186,16 @@  build_outer_var_ref (tree var, omp_context *ctx)
 	x = var;
     }
   else if (ctx->outer)
-    x = lookup_decl (var, ctx->outer);
+    {
+      omp_context *outer = ctx->outer;
+      if (gimple_code (outer->stmt) == GIMPLE_OMP_GPUKERNEL)
+	{
+	  outer = outer->outer;
+	  gcc_assert (outer
+		      && gimple_code (outer->stmt) != GIMPLE_OMP_GPUKERNEL);
+	}
+	x = lookup_decl (var, 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.  */