On Thu, Aug 19, 2021 at 10:13:56PM +0200, Thomas Schwinge wrote: > libgomp/ > * testsuite/libgomp.c/address-space-1.c: New file. > > Co-authored-by: Jakub Jelinek <ja...@redhat.com> > --- > libgomp/testsuite/libgomp.c/address-space-1.c | 24 +++++++++++++++++++ > 1 file changed, 24 insertions(+) > create mode 100644 libgomp/testsuite/libgomp.c/address-space-1.c > > diff --git a/libgomp/testsuite/libgomp.c/address-space-1.c > b/libgomp/testsuite/libgomp.c/address-space-1.c > new file mode 100644 > index 00000000000..90244db03b1 > --- /dev/null > +++ b/libgomp/testsuite/libgomp.c/address-space-1.c > @@ -0,0 +1,24 @@ > +/* Verify OMP instances of variables with address space. */ > + > +/* { dg-do run { target i?86-*-* x86_64-*-* } } */ > +/* { dg-require-effective-target offload_device_nonshared_as } */ > + > +#include <assert.h> > + > +int __seg_fs a; > + > +int > +main (void) > +{ > + // a = 123; // SIGSEGV > + int b; > +#pragma omp target map(alloc: a) map(from: b) > + { > + a = 321; // no SIGSEGV (given 'offload_device_nonshared_as') > + asm volatile ("" : : : "memory");
Maybe better asm volatile ("" : : "g" (&a) : "memory"); so that the compiler doesn't think it could optimize it away to just b = 321; Ok with that change. > + b = a; > + } > + assert (b == 321); > + > + return 0; > +} > -- > 2.30.2 > Jakub