diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2011-08-17 22:22:24 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2011-08-17 22:22:24 +0000 |
commit | 56efe24431b045be120d1fd5f6b0aa43a6b01c48 (patch) | |
tree | 61079456e621c36efec6f4efff6f91faaa0d8c76 /lib/Transforms/Scalar/DeadStoreElimination.cpp | |
parent | 0dd80b0d695b94b3baa8ec9195e9b41f3493da4f (diff) | |
download | external_llvm-56efe24431b045be120d1fd5f6b0aa43a6b01c48.zip external_llvm-56efe24431b045be120d1fd5f6b0aa43a6b01c48.tar.gz external_llvm-56efe24431b045be120d1fd5f6b0aa43a6b01c48.tar.bz2 |
Atomic load/store handling for the passes using memdep (GVN, DSE, memcpyopt).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137888 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/DeadStoreElimination.cpp')
-rw-r--r-- | lib/Transforms/Scalar/DeadStoreElimination.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/Transforms/Scalar/DeadStoreElimination.cpp b/lib/Transforms/Scalar/DeadStoreElimination.cpp index a645f92..8559147 100644 --- a/lib/Transforms/Scalar/DeadStoreElimination.cpp +++ b/lib/Transforms/Scalar/DeadStoreElimination.cpp @@ -213,9 +213,9 @@ getLocForRead(Instruction *Inst, AliasAnalysis &AA) { /// isRemovable - If the value of this instruction and the memory it writes to /// is unused, may we delete this instruction? static bool isRemovable(Instruction *I) { - // Don't remove volatile stores. + // Don't remove volatile/atomic stores. if (StoreInst *SI = dyn_cast<StoreInst>(I)) - return !SI->isVolatile(); + return SI->isUnordered(); IntrinsicInst *II = cast<IntrinsicInst>(I); switch (II->getIntrinsicID()) { @@ -447,7 +447,7 @@ bool DSE::runOnBasicBlock(BasicBlock &BB) { if (StoreInst *SI = dyn_cast<StoreInst>(Inst)) { if (LoadInst *DepLoad = dyn_cast<LoadInst>(InstDep.getInst())) { if (SI->getPointerOperand() == DepLoad->getPointerOperand() && - SI->getOperand(0) == DepLoad && !SI->isVolatile()) { + SI->getOperand(0) == DepLoad && isRemovable(SI)) { DEBUG(dbgs() << "DSE: Remove Store Of Load from same pointer:\n " << "LOAD: " << *DepLoad << "\n STORE: " << *SI << '\n'); @@ -670,6 +670,8 @@ bool DSE::handleEndBlock(BasicBlock &BB) { // If we encounter a use of the pointer, it is no longer considered dead if (LoadInst *L = dyn_cast<LoadInst>(BBI)) { + if (!L->isUnordered()) // Be conservative with atomic/volatile load + break; LoadedLoc = AA->getLocation(L); } else if (VAArgInst *V = dyn_cast<VAArgInst>(BBI)) { LoadedLoc = AA->getLocation(V); |