------- Comment #7 from jakub at gcc dot gnu dot org 2009-06-07 13:07 ------- valgrind just isn't smart enough to understand it. Obviously --enable-linux-futex build has a lot of synchronization primitives that are beyond what valgrind is able to understand, but even with the posix only primitives e.g.: static inline void *gomp_ptrlock_get (gomp_ptrlock_t *ptrlock) { if (ptrlock->ptr != NULL) return ptrlock->ptr;
gomp_mutex_lock (&ptrlock->lock); if (ptrlock->ptr != NULL) { gomp_mutex_unlock (&ptrlock->lock); return ptrlock->ptr; } return NULL; } is not something valgrind can understand. Try removing the first if/return and see if it helps drd. The reason why it is safe to do is that all supported libgomp targets have atomic pointer-sized loads/stores, and the pointer always starts as NULL and is only set to non-NULL value inside of a critical section guarded by the associated lock. Once it is non-NULL, it never changes its value again. So, if the inline sees the value non-NULL, it can safely assume it will be non-NULL all the time and doesn't have to take the lock... -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40362