[OpenMP] Add memory barrier to solve data race

Data race occurs when acquiring lock for critical section
triggering assertion failure. Added barrier to ensure
all memory is commited before checking assertion.

Reviewed By: Hahnfeld

Differential Revision: https://reviews.llvm.org/D76780
This commit is contained in:
Henry Kao
2020-03-27 16:29:05 -04:00
committed by Bryan Chan
parent 0fd8030be3
commit 236ac68fa5

View File

@@ -1239,6 +1239,9 @@ __kmp_acquire_queuing_lock_timed_template(kmp_queuing_lock_t *lck,
KMP_MB();
// ToDo: Use __kmp_wait_sleep or similar when blocktime != inf
KMP_WAIT(spin_here_p, FALSE, KMP_EQ, lck);
// Synchronize writes to both runtime thread structures
// and writes in user code.
KMP_MB();
#ifdef DEBUG_QUEUING_LOCKS
TRACE_LOCK(gtid + 1, "acq spin");