[llvm-commits] [llvm] r85896 - /llvm/trunk/lib/Transforms/IPO/LowerSetJmp.cpp
Benjamin Kramer
benny.kra at googlemail.com
Tue Nov 3 04:52:51 PST 2009
Author: d0k
Date: Tue Nov 3 06:52:50 2009
New Revision: 85896
URL: http://llvm.org/viewvc/llvm-project?rev=85896&view=rev
Log:
Eliminate some temporaries.
Modified:
llvm/trunk/lib/Transforms/IPO/LowerSetJmp.cpp
Modified: llvm/trunk/lib/Transforms/IPO/LowerSetJmp.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/LowerSetJmp.cpp?rev=85896&r1=85895&r2=85896&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/LowerSetJmp.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/LowerSetJmp.cpp Tue Nov 3 06:52:50 2009
@@ -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 @@
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 @@
// "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 @@
// 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 @@
// 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 @@
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
More information about the llvm-commits
mailing list