From: Benjamin Kramer Date: Tue, 3 Nov 2009 12:52:50 +0000 (+0000) Subject: Eliminate some temporaries. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=419e44edab26ae227fbc3b06db29243065d2845e;p=oota-llvm.git Eliminate some temporaries. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85896 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/IPO/LowerSetJmp.cpp b/lib/Transforms/IPO/LowerSetJmp.cpp index 0a55298e908..4d61e8345e0 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 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 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 Args = - make_vector(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