From 37ed3a41fbeb0c7ccafa1536718ae71ca76bf5a7 Mon Sep 17 00:00:00 2001 From: Anton Korobeynikov Date: Sun, 26 Aug 2007 21:43:30 +0000 Subject: 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 --- lib/Transforms/Utils/PromoteMemoryToRegister.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib/Transforms/Utils/PromoteMemoryToRegister.cpp') 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(*UI)) { - // noop + if (const LoadInst *LI = dyn_cast(*UI)) { + if (LI->isVolatile()) + return false; } else if (const StoreInst *SI = dyn_cast(*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. } -- cgit v1.1