Loading
[TSan][OpenMP][Archer] Treat all reduction operations as atomic
This patch rebases https://reviews.llvm.org/D108046 to the new ThreadSanitizer runtime. The idea of the new ThreadSanitizer Annotation function is to promote all memory accesses to be treated and logged as they would be explicit atomic accesses. I used the performance benchmark from the initial fiber review (https://reviews.llvm.org/D54889#1343582). The TSan-specific changes of this PR increase the execution time from 8.37 to 8.52 seconds on my system, which is a 1.8% runtime increase. The current tests for this new Annotation are integrated into the tests for the OpenMP-specific tool Archer. The new Annotations are used in Archer to promote all memory accesses performed to implement an OpenMP reduction as being atomic accesses. With these changes, ThreadSanitizer+Archer successfully detect the race in openmp/tools/archer/tests/races/parallel-for-array-reduction-no-barrier.c. The challenge in this test is to detect the race between the memory access from the primary thread before the reduction (line 30), which is not synchronized with the OpenMP reduction (line 31). The OpenMP CodeGen generates three different code patterns for the reduction from which the OpenMP runtime chooses one implementation at runtime. The new analysis is only compatible with two of these code patterns, therefore we skip generation of the third code pattern, if the TSan flag is present during compilation. Under review as #74631