This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[hsa] Fix ICE in build_outer_var_ref within GPUKERNEL


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 --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.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]