aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/SimplifyCFG.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-10-29 17:46:26 +0000
committerChris Lattner <sabre@nondot.org>2008-10-29 17:46:26 +0000
commitf8131c99de2ac66be4307ae24f2db44d12bc9b3f (patch)
tree4c917a1c21ef677a38c3d0e6b4859ecfea543c1f /lib/Transforms/Utils/SimplifyCFG.cpp
parent90e619afbef9886c65650d0464e3cc87deb8c298 (diff)
Fix PR2967 by not deleting volatile load/stores that occur before unreachable.
I don't really see this as being needed, but there is little harm from doing it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58385 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r--lib/Transforms/Utils/SimplifyCFG.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp
index 7f4133630d..596c5643e5 100644
--- a/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1932,7 +1932,18 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
while (Unreachable != BB->begin()) {
BasicBlock::iterator BBI = Unreachable;
--BBI;
+ // Do not delete instructions that can have side effects, like calls
+ // (which may never return) and volatile loads and stores.
if (isa<CallInst>(BBI)) break;
+
+ if (StoreInst *SI = dyn_cast<StoreInst>(BBI))
+ if (SI->isVolatile())
+ break;
+
+ if (LoadInst *LI = dyn_cast<LoadInst>(BBI))
+ if (LI->isVolatile())
+ break;
+
// Delete this instruction
BB->getInstList().erase(BBI);
Changed = true;