[PATCH] D83949: [TSan] Do not compound reads and writes when separated by atomics

Marco Elver via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 16 08:02:12 PDT 2020


melver added a comment.

In D83949#2155758 <https://reviews.llvm.org/D83949#2155758>, @dvyukov wrote:

> What would be an example of code where it matters?


For the kernel it doesn't matter, because we don't use builtin atomics (yet). The asm case works because it looks like a call.

For normal code, you could have something like:

  T0:
    x = load A  // data race
    atomic load acquire B // observes 1
    store A, ...
  
  T1:
    store A, ...
    atomic store release B, 1

If the current logic compounds this and TSAN only sees:

  T0:
    atomic load acquire B // observes 1
    store A, ...

we might miss the data race of the load on A. In practice, it probably doesn't really matter because T0 would probably load acquire spin on B or something better, and it'd be all in separate basic blocks.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83949/new/

https://reviews.llvm.org/D83949





More information about the llvm-commits mailing list