From: marxin Date: Wed, 23 Mar 2016 09:59:51 +0000 (+0000) Subject: Copy shadow argument conditionally (PR hsa/70337) X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b4a84f6b29486745eef138bfe8df7e789e6fb612;p=thirdparty%2Fgcc.git Copy shadow argument conditionally (PR hsa/70337) PR hsa/70337 * plugin/plugin-hsa.c (GOMP_OFFLOAD_run): Copy shadow argument just in case a dispatched kernel uses that argument. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@234418 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index fca65e638070..b3e735c5ddfc 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,9 @@ +2016-03-23 Martin Liska + + PR hsa/70337 + * plugin/plugin-hsa.c (GOMP_OFFLOAD_run): Copy shadow + argument just in case a dispatched kernel uses that argument. + 2016-03-16 Thomas Schwinge * testsuite/libgomp.oacc-fortran/kernels-loop-2.f95: Adjust to diff --git a/libgomp/plugin/plugin-hsa.c b/libgomp/plugin/plugin-hsa.c index d88849338dca..f7ef6000e1c9 100644 --- a/libgomp/plugin/plugin-hsa.c +++ b/libgomp/plugin/plugin-hsa.c @@ -1255,8 +1255,16 @@ GOMP_OFFLOAD_run (int n, void *fn_ptr, void *vars, void **args) hsa_signal_store_relaxed (s, 1); memcpy (shadow->kernarg_address, &vars, sizeof (vars)); - memcpy (shadow->kernarg_address + sizeof (vars), &shadow, - sizeof (struct hsa_kernel_runtime *)); + /* PR hsa/70337. */ + size_t vars_size = sizeof (vars); + if (kernel->kernarg_segment_size > vars_size) + { + if (kernel->kernarg_segment_size != vars_size + + sizeof (struct hsa_kernel_runtime *)) + GOMP_PLUGIN_fatal ("Kernel segment size has an unexpected value"); + memcpy (packet->kernarg_address + vars_size, &shadow, + sizeof (struct hsa_kernel_runtime *)); + } HSA_DEBUG ("Copying kernel runtime pointer to kernarg_address\n");