[WoA] Use fences for sequentially consistent stores/writes
LLVM currently uses LDAR/STLR and variants for acquire/release as well as seq_cst operations. This is fine as long as all code uses this convention. Normally LDAR/STLR act as one way barriers but when used in combination they provide a sequentially consistent model. i.e. when an LDAR appears after an STLR in program order the STLR acts as a two way fence and the store will be observed before the load. The problem is that normal loads (unlike ldar), when they appear after the STLR can be observed before STLR (if my understanding is correct). Possibly providing weaker than expected guarantees if they are used for ordered atomic operations. Unfortunately in Microsoft Visual Studio STL seq_cst ld/st are implemented using normal load/stores and explicit fences: dmb ish + str + dmb ish ldr + dmb ish This patch uses fences for MSVC target whenever we write to the memory in a sequentially consistent way so that we don't rely on the assumptions that just using LDAR/STLR will give us sequentially consistent ordering. Differential Revision: https://reviews.llvm.org/D141748 Change-Id: I48f3500ff8ec89677c9f089ce58181bd139bc68a
parent
a6a4fe20
Please register or sign in to comment