diff options
| author | Chris Lattner <sabre@nondot.org> | 2008-10-29 17:46:26 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2008-10-29 17:46:26 +0000 |
| commit | 0934c0f35b29d35cff1a41d39d3c540f6fea435e (patch) | |
| tree | 33ebce71541a9607ca8f1ba654a392f3aafa1806 /llvm/lib/Transforms/Utils | |
| parent | 49c28e4599552a74a5743ff54c892bb1443bab9b (diff) | |
| download | bcm5719-llvm-0934c0f35b29d35cff1a41d39d3c540f6fea435e.tar.gz bcm5719-llvm-0934c0f35b29d35cff1a41d39d3c540f6fea435e.zip | |
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.
llvm-svn: 58385
Diffstat (limited to 'llvm/lib/Transforms/Utils')
| -rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 7f4133630d8..596c5643e54 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/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; |

