[docs] Clarify where the indirect UB due to write-write races comes from
authorEli Friedman <efriedma@quicinc.com>
Tue, 23 Jul 2019 21:51:26 +0000 (21:51 +0000)
committerEli Friedman <efriedma@quicinc.com>
Tue, 23 Jul 2019 21:51:26 +0000 (21:51 +0000)
This is based on https://bugs.llvm.org/show_bug.cgi?id=42435#c3.

Patch by Ralf Jung.

llvm-svn: 366855

llvm/docs/Atomics.rst

index 450b5b3..60d7090 100644 (file)
@@ -87,8 +87,10 @@ The following is equivalent in non-concurrent situations:
 
 However, LLVM is not allowed to transform the former to the latter: it could
 indirectly introduce undefined behavior if another thread can access ``x`` at
-the same time. (This example is particularly of interest because before the
-concurrency model was implemented, LLVM would perform this transformation.)
+the same time. That thread would read `undef` instead of the value it was
+expecting, which can lead to undefined behavior down the line. (This example is
+particularly of interest because before the concurrency model was implemented,
+LLVM would perform this transformation.)
 
 Note that speculative loads are allowed; a load which is part of a race returns
 ``undef``, but does not have undefined behavior.