aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
diff options
context:
space:
mode:
authorAnton Korobeynikov <asl@math.spbu.ru>2007-08-26 21:43:30 +0000
committerAnton Korobeynikov <asl@math.spbu.ru>2007-08-26 21:43:30 +0000
commit9f528e628090ee0ffca35d4577c23b6544f9a119 (patch)
tree0ff81b463bee04f34f656bf4ab349891eaa06f78 /lib/Transforms/Utils/PromoteMemoryToRegister.cpp
parent5dfcf4318ab10da62a86cdce94f90c0a0cd42ad1 (diff)
Don't promote volatile loads/stores. This is needed (for example) to handle setjmp/longjmp properly.
This fixes PR1520. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41461 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/PromoteMemoryToRegister.cpp')
-rw-r--r--lib/Transforms/Utils/PromoteMemoryToRegister.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
index a6fb8707d4..3348971138 100644
--- a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
+++ b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
@@ -63,14 +63,17 @@ bool llvm::isAllocaPromotable(const AllocaInst *AI) {
// FIXME: If the memory unit is of pointer or integer type, we can permit
// assignments to subsections of the memory unit.
- // Only allow direct loads and stores...
+ // Only allow direct and non-volatile loads and stores...
for (Value::use_const_iterator UI = AI->use_begin(), UE = AI->use_end();
UI != UE; ++UI) // Loop over all of the uses of the alloca
- if (isa<LoadInst>(*UI)) {
- // noop
+ if (const LoadInst *LI = dyn_cast<LoadInst>(*UI)) {
+ if (LI->isVolatile())
+ return false;
} else if (const StoreInst *SI = dyn_cast<StoreInst>(*UI)) {
if (SI->getOperand(0) == AI)
return false; // Don't allow a store OF the AI, only INTO the AI.
+ if (SI->isVolatile())
+ return false;
} else {
return false; // Not a load or store.
}