summaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/Local.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-12-29 00:59:12 +0000
committerChris Lattner <sabre@nondot.org>2007-12-29 00:59:12 +0000
commit741c0aea08feab0ebd1932aaa8dd38836b2073ea (patch)
tree3a4b2801eec43c18234716a5e3f1572e4c5f83bb /lib/Transforms/Utils/Local.cpp
parent26d5f661d60e5d155508b7d3ef703d66ec4bc158 (diff)
downloadllvm-741c0aea08feab0ebd1932aaa8dd38836b2073ea.tar.gz
llvm-741c0aea08feab0ebd1932aaa8dd38836b2073ea.tar.bz2
llvm-741c0aea08feab0ebd1932aaa8dd38836b2073ea.tar.xz
dead calls to llvm.stacksave can be deleted, even though they
have potential side-effects. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45392 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/Local.cpp')
-rw-r--r--lib/Transforms/Utils/Local.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp
index 187ebdc797..4b648b3b8b 100644
--- a/lib/Transforms/Utils/Local.cpp
+++ b/lib/Transforms/Utils/Local.cpp
@@ -17,6 +17,7 @@
#include "llvm/DerivedTypes.h"
#include "llvm/Instructions.h"
#include "llvm/Intrinsics.h"
+#include "llvm/IntrinsicInst.h"
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Support/GetElementPtrTypeIterator.h"
@@ -173,8 +174,16 @@ bool llvm::ConstantFoldTerminator(BasicBlock *BB) {
bool llvm::isInstructionTriviallyDead(Instruction *I) {
if (!I->use_empty() || isa<TerminatorInst>(I)) return false;
- if (!I->mayWriteToMemory()) return true;
+ if (!I->mayWriteToMemory())
+ return true;
+ // Special case intrinsics that "may write to memory" but can be deleted when
+ // dead.
+ if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(I))
+ // Safe to delete llvm.stacksave if dead.
+ if (II->getIntrinsicID() == Intrinsic::stacksave)
+ return true;
+
return false;
}