summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
diff options
context:
space:
mode:
authorRobin Morisset <morisset@google.com>2014-08-18 22:18:11 +0000
committerRobin Morisset <morisset@google.com>2014-08-18 22:18:11 +0000
commit4ffe8aaa694acceb58c01ffea7c1684b3d80e2fe (patch)
treeacbf8b24832805bba53f10796dd2c0d3c50b1d2d /llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
parent00c02b297a4d360ecb42e4bdfa4479c2c827de5d (diff)
downloadbcm5719-llvm-4ffe8aaa694acceb58c01ffea7c1684b3d80e2fe.tar.gz
bcm5719-llvm-4ffe8aaa694acceb58c01ffea7c1684b3d80e2fe.zip
Weak relaxing of the constraints on atomics in MemoryDependencyAnalysis
Monotonic accesses do not have to kill the analysis, as long as the QueryInstr is not itself atomic. llvm-svn: 215942
Diffstat (limited to 'llvm/lib/Analysis/MemoryDependenceAnalysis.cpp')
-rw-r--r--llvm/lib/Analysis/MemoryDependenceAnalysis.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
index 59669372719..33fe425f135 100644
--- a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
+++ b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
@@ -409,9 +409,18 @@ getPointerDependencyFrom(const AliasAnalysis::Location &MemLoc, bool isLoad,
// a load depends on another must aliased load from the same value.
if (LoadInst *LI = dyn_cast<LoadInst>(Inst)) {
// Atomic loads have complications involved.
+ // A monotonic load is OK if the query inst is itself not atomic.
// FIXME: This is overly conservative.
- if (!LI->isUnordered())
- return MemDepResult::getClobber(LI);
+ if (!LI->isUnordered()) {
+ if (!QueryInst || LI->getOrdering() != Monotonic)
+ return MemDepResult::getClobber(LI);
+ if (auto *QueryLI = dyn_cast<LoadInst>(QueryInst))
+ if (!QueryLI->isUnordered())
+ return MemDepResult::getClobber(LI);
+ if (auto *QuerySI = dyn_cast<StoreInst>(QueryInst))
+ if (!QuerySI->isUnordered())
+ return MemDepResult::getClobber(LI);
+ }
AliasAnalysis::Location LoadLoc = AA->getLocation(LI);
@@ -469,9 +478,18 @@ getPointerDependencyFrom(const AliasAnalysis::Location &MemLoc, bool isLoad,
if (StoreInst *SI = dyn_cast<StoreInst>(Inst)) {
// Atomic stores have complications involved.
+ // A monotonic store is OK if the query inst is itself not atomic.
// FIXME: This is overly conservative.
- if (!SI->isUnordered())
- return MemDepResult::getClobber(SI);
+ if (!SI->isUnordered()) {
+ if (!QueryInst || SI->getOrdering() != Monotonic)
+ return MemDepResult::getClobber(SI);
+ if (auto *QueryLI = dyn_cast<LoadInst>(QueryInst))
+ if (!QueryLI->isUnordered())
+ return MemDepResult::getClobber(SI);
+ if (auto *QuerySI = dyn_cast<StoreInst>(QueryInst))
+ if (!QuerySI->isUnordered())
+ return MemDepResult::getClobber(SI);
+ }
// If alias analysis can tell that this store is guaranteed to not modify
// the query pointer, ignore it. Use getModRefInfo to handle cases where
OpenPOWER on IntegriCloud