#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/VectorExtras.h"
+#include "llvm/ADT/SmallVector.h"
using namespace llvm;
STATISTIC(LongJmpsTransformed, "Number of longjmps transformed");
bool IsTransformableFunction(const std::string& Name);
public:
- static const int ID; // Pass identifcation, replacement for typeid
+ static char ID; // Pass identification, replacement for typeid
LowerSetJmp() : ModulePass((intptr_t)&ID) {}
void visitCallInst(CallInst& CI);
bool doInitialization(Module& M);
};
- const int LowerSetJmp::ID = 0;
+ char LowerSetJmp::ID = 0;
RegisterPass<LowerSetJmp> X("lowersetjmp", "Lower Set Jump");
} // end anonymous namespace
// Inst's uses and doesn't get a name.
CastInst* CI =
new BitCastInst(Inst->getOperand(1), SBPTy, "LJBuf", Inst);
- new CallInst(ThrowLongJmp, CI, Inst->getOperand(2), "", Inst);
+ SmallVector<Value *, 2> Args;
+ Args.push_back(CI);
+ Args.push_back(Inst->getOperand(2));
+ new CallInst(ThrowLongJmp, Args.begin(), Args.end(), "", Inst);
SwitchValuePair& SVP = SwitchValMap[Inst->getParent()->getParent()];
make_vector<Value*>(GetSetJmpMap(Func), BufPtr,
ConstantInt::get(Type::Int32Ty,
SetJmpIDMap[Func]++), 0);
- new CallInst(AddSJToMap, &Args[0], Args.size(), "", Inst);
+ new CallInst(AddSJToMap, Args.begin(), Args.end(), "", 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
std::vector<Value*> Params(CI.op_begin() + 1, CI.op_end());
InvokeInst* II = new
InvokeInst(CI.getCalledValue(), NewBB, PrelimBBMap[Func],
- &Params[0], Params.size(), CI.getName(), Term);
+ Params.begin(), Params.end(), CI.getName(), Term);
+ II->setCallingConv(CI.getCallingConv());
+ II->setParamAttrs(CI.getParamAttrs());
// Replace the old call inst with the invoke inst and remove the call.
CI.replaceAllUsesWith(II);