aboutsummaryrefslogtreecommitdiffstats
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
commit37ed3a41fbeb0c7ccafa1536718ae71ca76bf5a7 (patch)
tree0ff81b463bee04f34f656bf4ab349891eaa06f78 /lib/Transforms/Utils/PromoteMemoryToRegister.cpp
parent82c44c3554a68a0f28ae97702e979843e604bcb8 (diff)
downloadexternal_llvm-37ed3a41fbeb0c7ccafa1536718ae71ca76bf5a7.zip
external_llvm-37ed3a41fbeb0c7ccafa1536718ae71ca76bf5a7.tar.gz
external_llvm-37ed3a41fbeb0c7ccafa1536718ae71ca76bf5a7.tar.bz2
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 a6fb870..3348971 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.
}