summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorAlina Sbirlea <asbirlea@google.com>2019-10-03 22:20:04 +0000
committerAlina Sbirlea <asbirlea@google.com>2019-10-03 22:20:04 +0000
commit145cdad11925194ec41949b5c8f0cb037f9e7941 (patch)
tree34a721da4d629d5b0430ee902d201dfdf6c63690 /llvm/lib
parent943a24812df0bc1993baec7db3a5d3b170118514 (diff)
downloadbcm5719-llvm-145cdad11925194ec41949b5c8f0cb037f9e7941.tar.gz
bcm5719-llvm-145cdad11925194ec41949b5c8f0cb037f9e7941.zip
[MemorySSA] Don't hoist stores if interfering uses (as calls) exist.
llvm-svn: 373674
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Scalar/LICM.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp
index 2e13e8e4150..262d64f1618 100644
--- a/llvm/lib/Transforms/Scalar/LICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LICM.cpp
@@ -1248,12 +1248,22 @@ bool llvm::canSinkOrHoistInst(Instruction &I, AAResults *AA, DominatorTree *DT,
// FIXME: More precise: no Uses that alias SI.
if (!Flags->IsSink && !MSSA->dominates(SIMD, MU))
return false;
- } else if (const auto *MD = dyn_cast<MemoryDef>(&MA))
+ } else if (const auto *MD = dyn_cast<MemoryDef>(&MA)) {
if (auto *LI = dyn_cast<LoadInst>(MD->getMemoryInst())) {
(void)LI; // Silence warning.
assert(!LI->isUnordered() && "Expected unordered load");
return false;
}
+ // Any call, while it may not be clobbering SI, it may be a use.
+ if (auto *CI = dyn_cast<CallInst>(MD->getMemoryInst())) {
+ // Check if the call may read from the memory locattion written
+ // to by SI. Check CI's attributes and arguments; the number of
+ // such checks performed is limited above by NoOfMemAccTooLarge.
+ ModRefInfo MRI = AA->getModRefInfo(CI, MemoryLocation::get(SI));
+ if (isModOrRefSet(MRI))
+ return false;
+ }
+ }
}
auto *Source = MSSA->getSkipSelfWalker()->getClobberingMemoryAccess(SI);
OpenPOWER on IntegriCloud