Skip to content

Commit

Permalink
[tsan] Suppress a benign race during metadata cache lookup
Browse files Browse the repository at this point in the history
This data race is benign and should not occur on the platforms we currently care about. However, do set the ordering appropriately when built with TSan to avoid reporting races from Swift code. The metadata lookup code relies on these orderings for synchronization.
  • Loading branch information
AnnaZaks committed Apr 6, 2016
1 parent 5320def commit d81c6ba
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/IRGen/GenMeta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,10 @@ void irgen::emitLazyCacheAccessFunction(IRGenModule &IGM,
// FIXME: Technically should be "consume", but that introduces barriers in the
// current LLVM ARM backend.
auto load = IGF.Builder.CreateLoad(cache);
// Make this barrier explicit when building for TSan to avoid false positives.
if (IGM.Opts.Sanitize == SanitizerKind::Thread)
load->setOrdering(llvm::AtomicOrdering::Acquire);


// Compare the load result against null.
auto isNullBB = IGF.createBasicBlock("cacheIsNull");
Expand Down

0 comments on commit d81c6ba

Please sign in to comment.