The attached patch silences false-positives found by tsan, a valgrind-based thread sanitizer. It's correct that there are races, but they're benign, hence the need to add annotations to suppress the reports. Here's what one report looks like on a trivial testcase:<div>
<br></div><div><div> WARNING: Possible data race during read of size 8 at 0x404130: {{{</div><div> T2 (L{}):</div><div> #0 llvm::ManagedStatic::operator* /home/nlewycky/llvm/include/llvm/Support/ManagedStatic.h:65</div>
<div> #1 test1::helper /home/nlewycky/llvm-thread-test.cc:8</div><div> Concurrent write(s) happened at (OR AFTER) these points:</div><div> T1 (L{}):</div><div> #0 llvm::ManagedStaticBase::RegisterManagedStatic /home/nlewycky/llvm/lib/Support/ManagedStatic.cpp:43</div>
<div> #1 llvm::ManagedStatic::operator* home/nlewycky/llvm/include/llvm/Support/ManagedStatic.h:67</div><div> #2 test1::helper /home/nlewycky/llvm-thread-test.cc:8</div><div> Address 0x404130 is 0 bytes inside data symbol "_ZN5test12msE"</div>
<div> Race verifier data: 0x400C28,0x400ECB</div><div> }}}</div></div><div><br></div><div>The annotations are calls to no-op functions, and compiled out entirely when either debug mode is off or ENABLE_THREADS is zero.</div>
<div><br></div><div>Please review!</div><div><br></div><div>Nick</div><div><br></div>