<div dir="ltr"><div>I've been poking around in old threads and in the GHC source, and I cannot find this documented anywhere. What are the guarantees that GHC provides around load/store reordering when it comes to using MVar or TVar+retry+atomically. For example:</div><div><br></div><div>import Data.Primitive</div><div>import Control.Concurrent.MVar</div><div>...</div><div>foo :: IO ()</div><div>foo = do</div><div>  ...</div><div>  writeByteArray myArr 13 (42 :: Word)</div><div>  putMVar myMVar ()</div><div><br></div><div>If there is another thread that calls takeMVar followed by `readByteArray myArr 13`, is it guaranteed by GHC to see the 42 that's been written to the array. Same question applies for situations using STM facilities to accomplish blocking behavior that MVar gives us. Any documentation or pointers to places in GHC source where these barriers are guaranteed would be appreciated.<br></div><div><br>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">-Andrew Thaddeus Martin</div></div></div>