diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2009-11-03 12:52:50 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2009-11-03 12:52:50 +0000 |
commit | 419e44edab26ae227fbc3b06db29243065d2845e (patch) | |
tree | 8eac30eabe23a9402c3477c80b41fccf3c098ba1 /lib/Transforms/IPO/LowerSetJmp.cpp | |
parent | 674fdc9a289c56edeb799bf5a8d4668f7e22bf73 (diff) | |
download | external_llvm-419e44edab26ae227fbc3b06db29243065d2845e.zip external_llvm-419e44edab26ae227fbc3b06db29243065d2845e.tar.gz external_llvm-419e44edab26ae227fbc3b06db29243065d2845e.tar.bz2 |
Eliminate some temporaries.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85896 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO/LowerSetJmp.cpp')
-rw-r--r-- | lib/Transforms/IPO/LowerSetJmp.cpp | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/lib/Transforms/IPO/LowerSetJmp.cpp b/lib/Transforms/IPO/LowerSetJmp.cpp index 0a55298..4d61e83 100644 --- a/lib/Transforms/IPO/LowerSetJmp.cpp +++ b/lib/Transforms/IPO/LowerSetJmp.cpp @@ -47,9 +47,6 @@ #include "llvm/Transforms/Utils/Local.h" #include "llvm/ADT/DepthFirstIterator.h" #include "llvm/ADT/Statistic.h" -#include "llvm/ADT/StringExtras.h" -#include "llvm/ADT/VectorExtras.h" -#include "llvm/ADT/SmallVector.h" #include <map> using namespace llvm; @@ -108,7 +105,7 @@ namespace { void TransformLongJmpCall(CallInst* Inst); void TransformSetJmpCall(CallInst* Inst); - bool IsTransformableFunction(const std::string& Name); + bool IsTransformableFunction(StringRef Name); public: static char ID; // Pass identification, replacement for typeid LowerSetJmp() : ModulePass(&ID) {} @@ -249,13 +246,8 @@ bool LowerSetJmp::doInitialization(Module& M) // "llvm.{setjmp,longjmp}" functions and none of the setjmp/longjmp error // handling functions (beginning with __llvm_sjljeh_...they don't throw // exceptions). -bool LowerSetJmp::IsTransformableFunction(const std::string& Name) { - std::string SJLJEh("__llvm_sjljeh"); - - if (Name.size() > SJLJEh.size()) - return std::string(Name.begin(), Name.begin() + SJLJEh.size()) != SJLJEh; - - return true; +bool LowerSetJmp::IsTransformableFunction(StringRef Name) { + return !Name.startswith("__llvm_sjljeh_"); } // TransformLongJmpCall - Transform a longjmp call into a call to the @@ -263,8 +255,7 @@ bool LowerSetJmp::IsTransformableFunction(const std::string& Name) { // throwing the exception for us. void LowerSetJmp::TransformLongJmpCall(CallInst* Inst) { - const Type* SBPTy = - Type::getInt8PtrTy(Inst->getContext()); + const Type* SBPTy = Type::getInt8PtrTy(Inst->getContext()); // Create the call to "__llvm_sjljeh_throw_longjmp". This takes the // same parameters as "longjmp", except that the buffer is cast to a @@ -272,10 +263,8 @@ void LowerSetJmp::TransformLongJmpCall(CallInst* Inst) // Inst's uses and doesn't get a name. CastInst* CI = new BitCastInst(Inst->getOperand(1), SBPTy, "LJBuf", Inst); - SmallVector<Value *, 2> Args; - Args.push_back(CI); - Args.push_back(Inst->getOperand(2)); - CallInst::Create(ThrowLongJmp, Args.begin(), Args.end(), "", Inst); + Value *Args[] = { CI, Inst->getOperand(2) }; + CallInst::Create(ThrowLongJmp, Args, Args + 2, "", Inst); SwitchValuePair& SVP = SwitchValMap[Inst->getParent()->getParent()]; @@ -390,11 +379,11 @@ void LowerSetJmp::TransformSetJmpCall(CallInst* Inst) Type::getInt8PtrTy(Inst->getContext()); CastInst* BufPtr = new BitCastInst(Inst->getOperand(1), SBPTy, "SBJmpBuf", Inst); - std::vector<Value*> Args = - make_vector<Value*>(GetSetJmpMap(Func), BufPtr, - ConstantInt::get(Type::getInt32Ty(Inst->getContext()), - SetJmpIDMap[Func]++), 0); - CallInst::Create(AddSJToMap, Args.begin(), Args.end(), "", Inst); + Value *Args[] = { + GetSetJmpMap(Func), BufPtr, + ConstantInt::get(Type::getInt32Ty(Inst->getContext()), SetJmpIDMap[Func]++) + }; + CallInst::Create(AddSJToMap, Args, Args + 3, "", Inst); // We are guaranteed that there are no values live across basic blocks // (because we are "not in SSA form" yet), but there can still be values live |