+ // 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()) {
+ if (!QueryInst)
+ return MemDepResult::getClobber(SI);
+ if (SI->getOrdering() != Monotonic)
+ return MemDepResult::getClobber(SI);
+ if (auto *QueryLI = dyn_cast<LoadInst>(QueryInst))
+ if (!QueryLI->isSimple())
+ return MemDepResult::getClobber(SI);
+ if (auto *QuerySI = dyn_cast<StoreInst>(QueryInst))
+ if (!QuerySI->isSimple())
+ return MemDepResult::getClobber(SI);
+ }
+
+ // FIXME: this is overly conservative.
+ // While volatile access cannot be eliminated, they do not have to clobber
+ // non-aliasing locations, as normal accesses can for example be reordered
+ // with volatile accesses.
+ if (SI->isVolatile())
+ return MemDepResult::getClobber(SI);
+