Allow value forwarding past release fences in EarlyCSE
authorPhilip Reames <listmail@philipreames.com>
Thu, 27 Aug 2015 01:32:33 +0000 (01:32 +0000)
committerPhilip Reames <listmail@philipreames.com>
Thu, 27 Aug 2015 01:32:33 +0000 (01:32 +0000)
commite7d1e02b6c5f30fb7494a8eceaa8b0f762892fd5
treed08a7c8f644195522dd3ecb3dbabaeb67282f616
parent33043ab31723fd090e84e08bdbd80fe1abf6b860
Allow value forwarding past release fences in EarlyCSE

A release fence acts as a publication barrier for stores within the current thread to become visible to other threads which might observe the release fence. It does not require the current thread to observe stores performed on other threads. As a result, we can allow store-load and load-store forwarding across a release fence.

We do need to make sure that stores before the fence can't be eliminated even if there's another store to the same location after the fence. In theory, we could reorder the second store above the fence and *then* eliminate the former, but we can't do this if the stores are on opposite sides of the fence.

Note: While more aggressive then what's there, this patch is still implementing a really conservative ordering.  In particular, I'm not trying to exploit undefined behavior via races, or the fact that the LangRef says only 'atomic' accesses are ordered w.r.t. fences.

Differential Revision: http://reviews.llvm.org/D11434

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246134 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/EarlyCSE.cpp
test/Transforms/EarlyCSE/fence.ll [new file with mode: 0644]