On Mon, 2021-05-17 at 21:02 -0400, Antoni Boucher via Jit wrote: > Hello. > This patch fixes the issue with using atomic builtins in libgccjit. > Thanks to review it.
[...snip...] > diff --git a/gcc/jit/jit-recording.c b/gcc/jit/jit-recording.c > index 117ff70114c..de876ff9fa6 100644 > --- a/gcc/jit/jit-recording.c > +++ b/gcc/jit/jit-recording.c > @@ -2598,8 +2598,18 @@ recording::memento_of_get_pointer::accepts_writes_from > (type *rtype) > return false; > > /* It's OK to assign to a (const T *) from a (T *). */ > - return m_other_type->unqualified () > - ->accepts_writes_from (rtype_points_to); > + if (m_other_type->unqualified () > + ->accepts_writes_from (rtype_points_to)) { > + return true; > + } > + > + /* It's OK to assign to a (volatile const T *) from a (volatile const T > *). */ > + if (m_other_type->unqualified ()->unqualified () > + ->accepts_writes_from (rtype_points_to->unqualified ())) { > + return true; > + } Presumably you need this to get the atomic builtins working? If I'm reading the above correctly, the new test doesn't distinguish between the 3 different kinds of qualifiers (aligned, volatile, and const), it merely tries to strip some of them off. It's not valid to e.g. assign to a (aligned T *) from a (const T *). Maybe we need an internal enum to discriminate between different subclasses of decorated_type? > + > + return false; > } > > /* Implementation of pure virtual hook recording::memento::replay_into > diff --git a/gcc/testsuite/jit.dg/all-non-failing-tests.h > b/gcc/testsuite/jit.dg/all-non-failing-tests.h > index 4202eb7798b..dfc6596358c 100644 > --- a/gcc/testsuite/jit.dg/all-non-failing-tests.h > +++ b/gcc/testsuite/jit.dg/all-non-failing-tests.h > @@ -181,6 +181,13 @@ > #undef create_code > #undef verify_code > > +/* test-builtin-types.c */ > +#define create_code create_code_builtin_types > +#define verify_code verify_code_builtin_types > +#include "test-builtin-types.c" > +#undef create_code > +#undef verify_code > + > /* test-hello-world.c */ > #define create_code create_code_hello_world > #define verify_code verify_code_hello_world As with various other patches, this needs to also add a new entry to the "testcases" array making use of the new {create|verify}_code_builtin_types functions. [...snip...] Hope this is constructive Dave