diff --git a/lib/Analysis/MemoryDependenceAnalysis.cpp b/lib/Analysis/MemoryDependenceAnalysis.cpp index aef241840ac..f7180aae69e 100644 --- a/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -449,12 +449,16 @@ getPointerDependencyFrom(const AliasAnalysis::Location &MemLoc, bool isLoad, if (!LI->isUnordered()) { if (!QueryInst) return MemDepResult::getClobber(LI); - if (auto *QueryLI = dyn_cast(QueryInst)) + if (auto *QueryLI = dyn_cast(QueryInst)) { if (!QueryLI->isSimple()) return MemDepResult::getClobber(LI); - if (auto *QuerySI = dyn_cast(QueryInst)) + } else if (auto *QuerySI = dyn_cast(QueryInst)) { if (!QuerySI->isSimple()) return MemDepResult::getClobber(LI); + } else if (QueryInst->mayReadOrWriteMemory()) { + return MemDepResult::getClobber(LI); + } + if (isAtLeastAcquire(LI->getOrdering())) HasSeenAcquire = true; } @@ -529,12 +533,16 @@ getPointerDependencyFrom(const AliasAnalysis::Location &MemLoc, bool isLoad, if (!SI->isUnordered()) { if (!QueryInst) return MemDepResult::getClobber(SI); - if (auto *QueryLI = dyn_cast(QueryInst)) + if (auto *QueryLI = dyn_cast(QueryInst)) { if (!QueryLI->isSimple()) return MemDepResult::getClobber(SI); - if (auto *QuerySI = dyn_cast(QueryInst)) + } else if (auto *QuerySI = dyn_cast(QueryInst)) { if (!QuerySI->isSimple()) return MemDepResult::getClobber(SI); + } else if (QueryInst->mayReadOrWriteMemory()) { + return MemDepResult::getClobber(SI); + } + if (HasSeenAcquire && isAtLeastRelease(SI->getOrdering())) return MemDepResult::getClobber(SI); }