summaryrefslogtreecommitdiffstats
path: root/llvm/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
commit24fb6b2f8c5a9856556e667be803de4ffde27ea0 (patch)
tree32a2de7d48e2330290e002241abd306b812e97b6 /llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
parentb633469e02c3aeb5f0087618dcc26ffb4be8c20b (diff)
downloadbcm5719-llvm-24fb6b2f8c5a9856556e667be803de4ffde27ea0.tar.gz
bcm5719-llvm-24fb6b2f8c5a9856556e667be803de4ffde27ea0.zip
Don't promote volatile loads/stores. This is needed (for example) to handle setjmp/longjmp properly.
This fixes PR1520. llvm-svn: 41461
Diffstat (limited to 'llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
index a6fb8707d41..33489711388 100644
--- a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
+++ b/llvm/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.
}
OpenPOWER on IntegriCloud