https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90859
Thomas Schwinge <tschwinge at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |openmp Last reconfirmed|2019-06-20 00:00:00 |2020-4-29 --- Comment #3 from Thomas Schwinge <tschwinge at gcc dot gnu.org> --- I've come across this again. And again, I'm just documenting this here, don't have bandwidth right now to figure out what's going on. (In reply to Thomas Schwinge from comment #0) > I noticed the following (with OpenACC, not yet tried to reproduce with > OpenMP 'target'). Now also reproduced for OpenMP. > Is there something wrong, or can that behavior be > explained? > > Only 'sizeof array' appears in the offloaded region, yet for 'target { c && > { ! lp64 } }' (only!), the gimplifier also creates a mapping for the array > itself. Now also reproduced on x86_64-pc-linux-gnu with default '-m64' instead of '-m32'. (In reply to Thomas Schwinge from comment #2) > Experimenting on x86_64-pc-linux-gnu with '-m32', this depends on the data > type used for 'array_so'. If I change 'uint32_t' to 'unsigned int', I see > the same strange behavior. If however I change it to 'unsigned long', the > issue goes away, as it does for 'unsigned short', for example. The code > inside the region is the same (aside from some type casting); in particular > there aren't any 'array' references. Similarly, with test case: #include <stdint.h> static void vla (int array_li) { _Complex double array[array_li]; TYPE array_so; #pragma omp target \ map(from:array_so) { array_so = sizeof array; } if (array_so != sizeof array) __builtin_abort (); } ... compiled with '-fopenmp -O0 -fdump-tree-gimple -DTYPE=int64_t', we get: #pragma omp target num_teams(1) thread_limit(0) map(from:array_so [len: 8]) firstprivate(array_li.0) { sizetype D.2157; sizetype D.2158; long int array_so.2; D.2157 = (sizetype) array_li.0; D.2158 = D.2157 * 16; array_so.2 = (long int) D.2158; array_so = array_so.2; } ..., but compiled with '-fopenmp -O0 -fdump-tree-gimple -DTYPE=uint64_t', we get: #pragma omp target num_teams(1) thread_limit(0) map(from:array_so [len: 8]) firstprivate(array_li.0) map(tofrom:(*array.1) [len: D.2153]) map(firstprivate:array [pointer assign, bias: 0]) { sizetype D.2157; sizetype array_so.2; D.2157 = (sizetype) array_li.0; array_so.2 = D.2157 * 16; array_so = array_so.2; } ..., that is, in the latter case, the 'array' itself gets mapped additionally, even though unused inside the region.