Update InvokeInst to work like CallInst
[oota-llvm.git] / lib / Transforms / IPO / LowerSetJmp.cpp
index 1fd90715d6b93a144a7c9839d1faf15409681730..dbc3199162a33f7d0f4b5a95d67b19c01cf7da0e 100644 (file)
@@ -49,6 +49,7 @@
 #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");
@@ -109,7 +110,7 @@ namespace {
 
     bool IsTransformableFunction(const std::string& Name);
   public:
-    static const char ID; // Pass identifcation, replacement for typeid
+    static char ID; // Pass identification, replacement for typeid
     LowerSetJmp() : ModulePass((intptr_t)&ID) {}
 
     void visitCallInst(CallInst& CI);
@@ -121,7 +122,7 @@ namespace {
     bool doInitialization(Module& M);
   };
 
-  const char LowerSetJmp::ID = 0;
+  char LowerSetJmp::ID = 0;
   RegisterPass<LowerSetJmp> X("lowersetjmp", "Lower Set Jump");
 } // end anonymous namespace
 
@@ -263,7 +264,10 @@ void LowerSetJmp::TransformLongJmpCall(CallInst* Inst)
   // 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()];
 
@@ -381,7 +385,7 @@ void LowerSetJmp::TransformSetJmpCall(CallInst* Inst)
     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
@@ -471,7 +475,7 @@ void LowerSetJmp::visitCallInst(CallInst& CI)
   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);
 
   // Replace the old call inst with the invoke inst and remove the call.
   CI.replaceAllUsesWith(II);