#ifndef LLVM_INSTRUCTIONS_H
#define LLVM_INSTRUCTIONS_H
+#include <iterator>
+
#include "llvm/InstrTypes.h"
+#include "llvm/DerivedTypes.h"
namespace llvm {
//===----------------------------------------------------------------------===//
// CallInst Class
//===----------------------------------------------------------------------===//
-
/// CallInst - This class represents a function call, abstracting a target
/// machine's calling convention. This class uses low bit of the SubClassData
/// field to indicate whether or not this is a tail call. The rest of the bits
/// hold the calling convention of the call.
///
+
class CallInst : public Instruction {
ParamAttrsList *ParamAttrs; ///< parameter attributes for call
CallInst(const CallInst &CI);
void init(Value *Func, Value *Actual);
void init(Value *Func);
+ template<typename InputIterator>
+ void init(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
+ const std::string &Name,
+ // This argument ensures that we have an iterator we can
+ // do arithmetic on in constant time
+ std::random_access_iterator_tag) {
+ typename std::iterator_traits<InputIterator>::difference_type NumArgs =
+ std::distance(ArgBegin, ArgEnd);
+
+ if (NumArgs > 0) {
+ // This requires that the iterator points to contiguous memory.
+ init(Func, &*ArgBegin, NumArgs);
+ }
+ else {
+ init(Func, 0, NumArgs);
+ }
+
+ setName(Name);
+ }
+
public:
+ /// Construct a CallInst given a range of arguments. InputIterator
+ /// must be a random-access iterator pointing to contiguous storage
+ /// (e.g. a std::vector<>::iterator). Checks are made for
+ /// random-accessness but not for contiguous storage as that would
+ /// incur runtime overhead.
+ /// @brief Construct a CallInst from a range of arguments
+ template<typename InputIterator>
+ CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
+ const std::string &Name = "", Instruction *InsertBefore = 0)
+ : Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
+ ->getElementType())->getReturnType(),
+ Instruction::Call, 0, 0, InsertBefore) {
+ init(Func, ArgBegin, ArgEnd, Name,
+ typename std::iterator_traits<InputIterator>::iterator_category());
+ }
+
+ /// Construct a CallInst given a range of arguments. InputIterator
+ /// must be a random-access iterator pointing to contiguous storage
+ /// (e.g. a std::vector<>::iterator). Checks are made for
+ /// random-accessness but not for contiguous storage as that would
+ /// incur runtime overhead.
+ /// @brief Construct a CallInst from a range of arguments
+ template<typename InputIterator>
+ CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
+ const std::string &Name, BasicBlock *InsertAtEnd)
+ : Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
+ ->getElementType())->getReturnType(),
+ Instruction::Call, 0, 0, InsertAtEnd) {
+ init(Func, ArgBegin, ArgEnd, Name,
+ typename std::iterator_traits<InputIterator>::iterator_category());
+ }
+
+#if 0
+ // Leave these here for llvm-gcc
CallInst(Value *F, Value* const *Args, unsigned NumArgs,
const std::string &Name = "", Instruction *InsertBefore = 0);
CallInst(Value *F, Value *const *Args, unsigned NumArgs,
const std::string &Name, BasicBlock *InsertAtEnd);
-
+
// Alternate CallInst ctors w/ two actuals, w/ one actual and no
// actuals, respectively.
CallInst(Value *F, Value *Actual1, Value *Actual2,
const std::string& Name = "", Instruction *InsertBefore = 0);
CallInst(Value *F, Value *Actual1, Value *Actual2,
const std::string& Name, BasicBlock *InsertAtEnd);
+#endif
CallInst(Value *F, Value *Actual, const std::string& Name = "",
Instruction *InsertBefore = 0);
CallInst(Value *F, Value *Actual, const std::string& Name,
}
CallInst *CreateCall(Value *Callee, const char *Name = "") {
- return Insert(new CallInst(Callee, (Value**)0, 0, Name));
+ return Insert(new CallInst(Callee, Name));
}
CallInst *CreateCall(Value *Callee, Value *Arg, const char *Name = "") {
- return Insert(new CallInst(Callee, &Arg, 1, Name));
+ return Insert(new CallInst(Callee, Arg, Name));
}
- CallInst *CreateCall(Value *Callee, Value *Arg0, Value *Arg1,
+
+ template<typename InputIterator>
+ CallInst *CreateCall(Value *Callee, InputIterator ArgBegin, InputIterator ArgEnd,
const char *Name = "") {
- Value *Args[] = { Arg0, Arg1 };
- return Insert(new CallInst(Callee, Args, 2, Name));
+ return(Insert(new CallInst(Callee, ArgBegin, ArgEnd, Name)));
}
-
+#if 0
+ CallInst *CreateCall(Value *Callee, Value *Arg0, Value *Arg1,
+ const char *Name = "") {
+ Value *Args[] = { Arg0, Arg1 };
+ return Insert(new CallInst(Callee, Args, Args+2, Name));
+ }
+
+ // Leave this here for llvm-gcc
CallInst *CreateCall(Value *Callee, Value* const *Args, unsigned NumArgs,
const char *Name = "") {
- return Insert(new CallInst(Callee, Args, NumArgs, Name));
+ return Insert(new CallInst(Callee, Args, Args+NumArgs, Name));
}
+#endif
SelectInst *CreateSelect(Value *C, Value *True, Value *False,
const char *Name = "") {
GEN_ERROR("Invalid number of parameters detected");
}
// Create the call node
- CallInst *CI = new CallInst(V, &Args[0], Args.size());
+ CallInst *CI = new CallInst(V, Args.begin(), Args.end());
CI->setTailCall($1);
CI->setCallingConv($2);
$$ = CI;
}
}
- I = new CallInst(Callee, &Args[0], Args.size());
+ I = new CallInst(Callee, Args.begin(), Args.end());
cast<CallInst>(I)->setCallingConv(CCInfo>>1);
cast<CallInst>(I)->setTailCall(CCInfo & 1);
break;
FunctionType::get(RetTy, ParamTys, false));
}
- SmallVector<Value*, 8> Operands(ArgBegin, ArgEnd);
- CallInst *NewCI = new CallInst(FCache, &Operands[0], Operands.size(),
+ SmallVector<Value *, 8> Args(ArgBegin, ArgEnd);
+ CallInst *NewCI = new CallInst(FCache, Args.begin(), Args.end(),
CI->getName(), CI);
if (!CI->use_empty())
CI->replaceAllUsesWith(NewCI);
CI->getOperand(2),
CI->getOperand(3)
};
- return new CallInst(F, Args, sizeof(Args)/sizeof(Args[0]), CI->getName(), CI);
+ return new CallInst(F, Args, Args+sizeof(Args)/sizeof(Args[0]), CI->getName(), CI);
}
/// Convert the llvm.part.set.iX.iY.iZ intrinsic. This intrinsic takes
CI->getOperand(3),
CI->getOperand(4)
};
- return new CallInst(F, Args, sizeof(Args)/sizeof(Args[0]), CI->getName(), CI);
+ return new CallInst(F, Args, Args+sizeof(Args)/sizeof(Args[0]), CI->getName(), CI);
}
Args.push_back(C);
}
- CallInst *TheCall = new CallInst(F, &Args[0], Args.size(), "", StubBB);
+ CallInst *TheCall = new CallInst(F, Args.begin(), Args.end(), "", StubBB);
TheCall->setTailCall();
if (TheCall->getType() != Type::VoidTy)
new ReturnInst(TheCall, StubBB); // Return result of the call.
&Args[0], Args.size(), "", Call);
cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
} else {
- New = new CallInst(NF, &Args[0], Args.size(), "", Call);
+ New = new CallInst(NF, Args.begin(), Args.end(), "", Call);
cast<CallInst>(New)->setCallingConv(CS.getCallingConv());
if (cast<CallInst>(Call)->isTailCall())
cast<CallInst>(New)->setTailCall();
&Args[0], Args.size(), "", Call);
cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
} else {
- New = new CallInst(NF, &Args[0], Args.size(), "", Call);
+ New = new CallInst(NF, Args.begin(), Args.end(), "", Call);
cast<CallInst>(New)->setCallingConv(CS.getCallingConv());
if (cast<CallInst>(Call)->isTailCall())
cast<CallInst>(New)->setTailCall();
&Args[0], Args.size(), "", Call);
cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
} else {
- New = new CallInst(NF, &Args[0], Args.size(), "", Call);
+ New = new CallInst(NF, Args.begin(), Args.end(), "", Call);
cast<CallInst>(New)->setCallingConv(CS.getCallingConv());
if (cast<CallInst>(Call)->isTailCall())
cast<CallInst>(New)->setTailCall();
#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");
// 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
SmallVector<Value*, 8> Args(II->op_begin()+3, II->op_end());
// Insert a call instruction before the invoke.
CallInst *Call = new CallInst(II->getCalledValue(),
- &Args[0], Args.size(), "", II);
+ Args.begin(), Args.end(), "", II);
Call->takeName(II);
Call->setCallingConv(II->getCallingConv());
ConstantInt::get(SLC.getIntPtrType(), SrcStr.size()+1), // copy nul byte.
ConstantInt::get(Type::Int32Ty, 1) // alignment
};
- new CallInst(SLC.get_memcpy(), Vals, 4, "", CI);
+ new CallInst(SLC.get_memcpy(), Vals, Vals + 4, "", CI);
return ReplaceCallWith(CI, Dst);
}
CI->getOperand(2),
ConstantInt::get(SLC.getIntPtrType(), Str.size()+1)
};
- return ReplaceCallWith(CI, new CallInst(SLC.get_memchr(), Args, 3,
+ return ReplaceCallWith(CI, new CallInst(SLC.get_memchr(), Args, Args + 3,
CI->getName(), CI));
}
ConstantInt::get(SLC.getIntPtrType(), SrcStr.size()+1),
ConstantInt::get(Type::Int32Ty, 1) // alignment
};
- new CallInst(SLC.get_memcpy(), MemcpyOps, 4, "", CI);
+ new CallInst(SLC.get_memcpy(), MemcpyOps, MemcpyOps + 4, "", CI);
return ReplaceCallWith(CI, Dst);
}
ConstantInt::get(SLC.getIntPtrType(), 1),
CI->getOperand(1)
};
- new CallInst(SLC.get_fwrite(FILEty), FWriteArgs, 4, CI->getName(), CI);
+ new CallInst(SLC.get_fwrite(FILEty), FWriteArgs, FWriteArgs + 4, CI->getName(), CI);
return ReplaceCallWith(CI, ConstantInt::get(CI->getType(),
FormatStr.size()));
}
const Type *FILETy = CI->getOperand(1)->getType();
Value *C = CastInst::createZExtOrBitCast(CI->getOperand(3), Type::Int32Ty,
CI->getName()+".int", CI);
- new CallInst(SLC.get_fputc(FILETy), C, CI->getOperand(1), "", CI);
+ SmallVector<Value *, 2> Args;
+ Args.push_back(C);
+ Args.push_back(CI->getOperand(1));
+ new CallInst(SLC.get_fputc(FILETy), Args.begin(), Args.end(), "", CI);
return ReplaceCallWith(CI, ConstantInt::get(CI->getType(), 1));
}
case 's': {
return false;
// fprintf(file,"%s",str) -> fputs(str,file)
- new CallInst(SLC.get_fputs(FILETy), CastToCStr(CI->getOperand(3), CI),
- CI->getOperand(1), CI->getName(), CI);
+ SmallVector<Value *, 2> Args;
+ Args.push_back(CastToCStr(CI->getOperand(3), CI));
+ Args.push_back(CI->getOperand(1));
+ new CallInst(SLC.get_fputs(FILETy), Args.begin(),
+ Args.end(), CI->getName(), CI);
return ReplaceCallWith(CI, 0);
}
default:
FormatStr.size()+1), // Copy the nul byte.
ConstantInt::get(Type::Int32Ty, 1)
};
- new CallInst(SLC.get_memcpy(), MemCpyArgs, 4, "", CI);
+ new CallInst(SLC.get_memcpy(), MemCpyArgs, MemCpyArgs + 4, "", CI);
return ReplaceCallWith(CI, ConstantInt::get(CI->getType(),
FormatStr.size()));
}
Len,
ConstantInt::get(Type::Int32Ty, 1)
};
- new CallInst(SLC.get_memcpy(), MemcpyArgs, 4, "", CI);
+ new CallInst(SLC.get_memcpy(), MemcpyArgs, MemcpyArgs + 4, "", CI);
// The strlen result is the unincremented number of bytes in the string.
if (!CI->use_empty()) {
ConstantInt::get(SLC.getIntPtrType(), 1),
CI->getOperand(2)
};
- new CallInst(SLC.get_fwrite(FILETy), FWriteParms, 4, "", CI);
+ new CallInst(SLC.get_fwrite(FILETy), FWriteParms, FWriteParms + 4, "", CI);
return ReplaceCallWith(CI, 0); // Known to have no uses (see above).
}
} FPutsOptimizer;
// If this is writing one byte, turn it into fputc.
if (EltSize == 1 && EltCount == 1) {
+ SmallVector<Value *, 2> Args;
// fwrite(s,1,1,F) -> fputc(s[0],F)
Value *Ptr = CI->getOperand(1);
Value *Val = new LoadInst(Ptr, Ptr->getName()+".byte", CI);
- Val = new ZExtInst(Val, Type::Int32Ty, Val->getName()+".int", CI);
+ Args.push_back(new ZExtInst(Val, Type::Int32Ty, Val->getName()+".int", CI));
+ Args.push_back(CI->getOperand(4));
const Type *FILETy = CI->getOperand(4)->getType();
- new CallInst(SLC.get_fputc(FILETy), Val, CI->getOperand(4), "", CI);
+ new CallInst(SLC.get_fputc(FILETy), Args.begin(), Args.end(), "", CI);
return ReplaceCallWith(CI, ConstantInt::get(CI->getType(), 1));
}
return false;
}
Args[3] = ConstantInt::get(Type::Int32Ty, NumElements);
- Instruction *InitCall = new CallInst(InitFn, &Args[0], Args.size(),
+ Instruction *InitCall = new CallInst(InitFn, Args.begin(), Args.end(),
"newargc", InsertPos);
// If argc or argv are not available in main, just pass null values in.
// The function cannot unwind. Convert it to a call with a branch
// after it to the normal destination.
SmallVector<Value*, 8> Args(II->op_begin()+3, II->op_end());
- CallInst *NewCall = new CallInst(F, &Args[0], Args.size(), "", II);
+ CallInst *NewCall = new CallInst(F, Args.begin(), Args.end(), "", II);
NewCall->takeName(II);
NewCall->setCallingConv(II->getCallingConv());
II->replaceAllUsesWith(NewCall);
&Args[0], Args.size(), Caller->getName(), Caller);
cast<InvokeInst>(NC)->setCallingConv(II->getCallingConv());
} else {
- NC = new CallInst(Callee, &Args[0], Args.size(), Caller->getName(), Caller);
+ NC = new CallInst(Callee, Args.begin(), Args.end(), Caller->getName(), Caller);
if (cast<CallInst>(Caller)->isTailCall())
cast<CallInst>(NC)->setTailCall();
cast<CallInst>(NC)->setCallingConv(cast<CallInst>(Caller)->getCallingConv());
#include "llvm/Module.h"
#include "llvm/Pass.h"
#include "llvm/Support/Compiler.h"
+#include "llvm/ADT/SmallVector.h"
using namespace llvm;
namespace {
CI->setOperand(0, GCRead);
} else {
// Create a whole new call to replace the old one.
- CallInst *NC = new CallInst(GCRead, CI->getOperand(1),
- CI->getOperand(2),
+
+ // It sure would be nice to pass op_begin()+1,
+ // op_begin()+2 but it runs into trouble with
+ // CallInst::init's &*ierator, which requires a
+ // conversion from Use* to Value*. The conversion
+ // from Use to Value * is not useful because the
+ // memory for Value * won't be contiguous.
+ SmallVector<Value *, 2> Args;
+ Args.push_back(CI->getOperand(1));
+ Args.push_back(CI->getOperand(2));
+ CallInst *NC = new CallInst(GCRead, Args.begin(),
+ Args.end(),
CI->getName(), CI);
// These functions only deal with ptr type results so BitCast
// is the correct kind of cast (no-op cast).
ConstantInt::get(MI->getOperand(3)->getType(), EltSize), // Size
Zero // Align
};
- new CallInst(TheFn, Ops, 4, "", MI);
+ new CallInst(TheFn, Ops, Ops + 4, "", MI);
} else {
assert(isa<MemSetInst>(MI));
Value *Ops[] = {
ConstantInt::get(MI->getOperand(3)->getType(), EltSize), // Size
Zero // Align
};
- new CallInst(TheFn, Ops, 4, "", MI);
+ new CallInst(TheFn, Ops, Ops + 4, "", MI);
}
}
}
// Emit the call to the function
- CallInst *call = new CallInst(newFunction, ¶ms[0], params.size(),
+ CallInst *call = new CallInst(newFunction, params.begin(), params.end(),
NumExitBlocks > 1 ? "targetBlock" : "");
codeReplacer->getInstList().push_back(call);
std::vector<Value*> CallArgs(II->op_begin()+3, II->op_end());
// Insert a normal call instruction...
CallInst *NewCall = new CallInst(II->getCalledValue(),
- &CallArgs[0], CallArgs.size(), "", II);
+ CallArgs.begin(), CallArgs.end(), "", II);
NewCall->takeName(II);
NewCall->setCallingConv(II->getCallingConv());
II->replaceAllUsesWith(NewCall);
// Insert a normal call instruction.
std::vector<Value*> CallArgs(II->op_begin()+3, II->op_end());
CallInst *NewCall = new CallInst(II->getCalledValue(),
- &CallArgs[0], CallArgs.size(), "",
+ CallArgs.begin(), CallArgs.end(), "",
II);
NewCall->takeName(II);
NewCall->setCallingConv(II->getCallingConv());
Idx.push_back(ConstantInt::get(Type::Int32Ty, 0));
Idx[0] = new GetElementPtrInst(BufPtr, &Idx[0], 2, "JmpBuf", UnwindBlock);
Idx[1] = ConstantInt::get(Type::Int32Ty, 1);
- new CallInst(LongJmpFn, &Idx[0], Idx.size(), "", UnwindBlock);
+ new CallInst(LongJmpFn, Idx.begin(), Idx.end(), "", UnwindBlock);
new UnreachableInst(UnwindBlock);
// Set up the term block ("throw without a catch").
// Insert the call now...
SmallVector<Value*,8> Args(II->op_begin()+3, II->op_end());
CallInst *CI = new CallInst(II->getCalledValue(),
- &Args[0], Args.size(), II->getName(), BI);
+ Args.begin(), Args.end(), II->getName(), BI);
CI->setCallingConv(II->getCallingConv());
// If the invoke produced a value, the Call now does instead
II->replaceAllUsesWith(CI);
// Insert the call now...
SmallVector<Value*, 8> Args(II->op_begin()+3, II->op_end());
CallInst *CI = new CallInst(II->getCalledValue(),
- &Args[0], Args.size(),
+ Args.begin(), Args.end(),
II->getName(), BI);
CI->setCallingConv(II->getCallingConv());
// If the invoke produced a value, the Call does now instead.
assert(FTy->getNumParams() == 0 && "Calling a function with bad signature");
}
+#if 0
+// Leave for llvm-gcc
CallInst::CallInst(Value *Func, Value* const *Args, unsigned NumArgs,
const std::string &Name, BasicBlock *InsertAtEnd)
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
- ->getElementType())->getReturnType(),
+ ->getElementType())->getReturnType(),
Instruction::Call, 0, 0, InsertAtEnd) {
init(Func, Args, NumArgs);
setName(Name);
}
CallInst::CallInst(Value *Func, Value* const *Args, unsigned NumArgs,
const std::string &Name, Instruction *InsertBefore)
-: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
- ->getElementType())->getReturnType(),
- Instruction::Call, 0, 0, InsertBefore) {
+ : Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
+ ->getElementType())->getReturnType(),
+ Instruction::Call, 0, 0, InsertBefore) {
init(Func, Args, NumArgs);
setName(Name);
}
init(Func, Actual1, Actual2);
setName(Name);
}
-
+#endif
CallInst::CallInst(Value *Func, Value* Actual, const std::string &Name,
Instruction *InsertBefore)
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
init(Func, Actual);
setName(Name);
}
-
CallInst::CallInst(Value *Func, const std::string &Name,
Instruction *InsertBefore)
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
// Call the old main function and return its result
BasicBlock *BB = new BasicBlock("entry", newMain);
- CallInst *call = new CallInst(oldMainProto, &args[0], args.size(),
+ CallInst *call = new CallInst(oldMainProto, args.begin(), args.end(),
"", BB);
// If the type of old function wasn't void, return value of call
// Resolve the call to function F via the JIT API:
//
// call resolver(GetElementPtr...)
- CallInst *Resolver = new CallInst(resolverFunc, &ResolverArgs[0],
- ResolverArgs.size(),
+ CallInst *Resolver = new CallInst(resolverFunc, ResolverArgs.begin(),
+ ResolverArgs.end(),
"resolver", LookupBB);
// cast the result from the resolver to correctly-typed function
CastInst *CastedResolver = new BitCastInst(Resolver,
// Pass on the arguments to the real function, return its result
if (F->getReturnType() == Type::VoidTy) {
- new CallInst(FuncPtr, &Args[0], Args.size(), "", DoCallBB);
+ new CallInst(FuncPtr, Args.begin(), Args.end(), "", DoCallBB);
new ReturnInst(DoCallBB);
} else {
- CallInst *Call = new CallInst(FuncPtr, &Args[0], Args.size(),
+ CallInst *Call = new CallInst(FuncPtr, Args.begin(), Args.end(),
"retval", DoCallBB);
new ReturnInst(Call, DoCallBB);
}
const PointerType *PFTy = PointerType::get(FTy);
Value* Func = getVal(PFTy, ID);
Args[0] = new BitCastInst(Args[0], PtrTy, makeNameUnique("va"), CurBB);
- return new CallInst(Func, &Args[0], Args.size());
+ return new CallInst(Func, Args.begin(), Args.end());
} else if (Name == "llvm.va_copy") {
if (Args.size() != 2)
error("Invalid prototype for " + Name + " prototype");
std::string InstName1(makeNameUnique("va1"));
Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB);
Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB);
- return new CallInst(Func, &Args[0], Args.size());
+ return new CallInst(Func, Args.begin(), Args.end());
}
}
}
while (!F->use_empty()) {
CallInst* CI = cast<CallInst>(F->use_back());
- AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
- AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
- new StoreInst(CI->getOperand(1), b, CI);
- new CallInst(NF, a, b, "", CI);
- Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
+ SmallVector<Value *, 2> Args;
+ Args.push_back(new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI));
+ Args.push_back(new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI));
+ new StoreInst(CI->getOperand(1), Args[1], CI);
+ new CallInst(NF, Args.begin(), Args.end(), "", CI);
+ Value* foo = new LoadInst(Args[0], "vacopy.fix.3", CI);
CI->replaceAllUsesWith(foo);
CI->getParent()->getInstList().erase(CI);
}
}
// Create the call instruction
- CallInst *CI = new CallInst(V, &Args[0], Args.size());
+ CallInst *CI = new CallInst(V, Args.begin(), Args.end());
CI->setTailCall($1);
CI->setCallingConv(upgradeCallingConv($2));
$$.I = CI;