Refine memory dependence's notion of volatile semantics
authorPhilip Reames <listmail@philipreames.com>
Mon, 26 Jan 2015 18:54:27 +0000 (18:54 +0000)
committerPhilip Reames <listmail@philipreames.com>
Mon, 26 Jan 2015 18:54:27 +0000 (18:54 +0000)
commitcce3c83917c2486928bb334bbb7aa501edda7c40
tree90ef64544e28415d00631b54367d271857f3875e
parent956d6f0cf5cdb41e89853202fd46fb520909640c
Refine memory dependence's notion of volatile semantics

According to my reading of the LangRef, volatiles are only ordered with respect to other volatiles. It is entirely legal and profitable to forward unrelated loads over the volatile load. This patch implements this for GVN by refining the transition rules MemoryDependenceAnalysis uses when encountering a volatile.

The added test cases show where the extra flexibility is profitable for local dependence optimizations. I have a related change (227110) which will extend this to non-local dependence (i.e. PRE), but that's essentially orthogonal to the semantic change in this patch. I have tested the two together and can confirm that PRE works over a volatile load with both changes.  I will be submitting a PRE w/volatiles test case seperately in the near future.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227112 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/MemoryDependenceAnalysis.cpp
test/Transforms/GVN/volatile.ll [new file with mode: 0644]