mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-25 00:29:20 +00:00
Convert CallInst and InvokeInst APIs to use ArrayRef.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135265 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e083805724
commit
a3efbb15dd
@ -616,6 +616,7 @@ from the previous release.</p>
|
|||||||
include:
|
include:
|
||||||
<ul>
|
<ul>
|
||||||
<!-- Please keep this list sorted. -->
|
<!-- Please keep this list sorted. -->
|
||||||
|
<li><code>CallInst::Create</code></li>
|
||||||
<li><code>ComputeLinearIndex</code> (in <code>llvm/CodeGen/Analysis.h</code>)</li>
|
<li><code>ComputeLinearIndex</code> (in <code>llvm/CodeGen/Analysis.h</code>)</li>
|
||||||
<li><code>ConstantArray::get</code></li>
|
<li><code>ConstantArray::get</code></li>
|
||||||
<li><code>ConstantExpr::getExtractElement</code></li>
|
<li><code>ConstantExpr::getExtractElement</code></li>
|
||||||
@ -629,10 +630,13 @@ from the previous release.</p>
|
|||||||
<li><code>ExtractValueInst::getIndexedType</code></li>
|
<li><code>ExtractValueInst::getIndexedType</code></li>
|
||||||
<li><code>ExtractValueInst::getIndices</code></li>
|
<li><code>ExtractValueInst::getIndices</code></li>
|
||||||
<li><code>FindInsertedValue</code> (in <code>llvm/Analysis/ValueTracking.h</code>)</li>
|
<li><code>FindInsertedValue</code> (in <code>llvm/Analysis/ValueTracking.h</code>)</li>
|
||||||
|
<li><code>IRBuilder::CreateCall</code></li>
|
||||||
<li><code>IRBuilder::CreateExtractValue</code></li>
|
<li><code>IRBuilder::CreateExtractValue</code></li>
|
||||||
<li><code>IRBuilder::CreateInsertValue</code></li>
|
<li><code>IRBuilder::CreateInsertValue</code></li>
|
||||||
|
<li><code>IRBuilder::CreateInvoke</code></li>
|
||||||
<li><code>InsertValueInst::Create</code></li>
|
<li><code>InsertValueInst::Create</code></li>
|
||||||
<li><code>InsertValueInst::getIndices</code></li>
|
<li><code>InsertValueInst::getIndices</code></li>
|
||||||
|
<li><code>InvokeInst::Create</code></li>
|
||||||
<li><code>MDNode::get</code></li>
|
<li><code>MDNode::get</code></li>
|
||||||
<li><code>MDNode::getIfExists</code></li>
|
<li><code>MDNode::getIfExists</code></li>
|
||||||
<li><code>MDNode::getTemporary</code></li>
|
<li><code>MDNode::getTemporary</code></li>
|
||||||
|
@ -842,46 +842,17 @@ public:
|
|||||||
class CallInst : public Instruction {
|
class CallInst : public Instruction {
|
||||||
AttrListPtr AttributeList; ///< parameter attributes for call
|
AttrListPtr AttributeList; ///< parameter attributes for call
|
||||||
CallInst(const CallInst &CI);
|
CallInst(const CallInst &CI);
|
||||||
void init(Value *Func, Value* const *Params, unsigned NumParams);
|
void init(Value *Func, ArrayRef<Value *> Args, const Twine &NameStr);
|
||||||
void init(Value *Func, Value *Actual1, Value *Actual2);
|
void init(Value *Func, const Twine &NameStr);
|
||||||
void init(Value *Func, Value *Actual);
|
|
||||||
void init(Value *Func);
|
|
||||||
|
|
||||||
template<typename RandomAccessIterator>
|
/// Construct a CallInst given a range of arguments.
|
||||||
void init(Value *Func,
|
|
||||||
RandomAccessIterator ArgBegin,
|
|
||||||
RandomAccessIterator ArgEnd,
|
|
||||||
const Twine &NameStr,
|
|
||||||
// This argument ensures that we have an iterator we can
|
|
||||||
// do arithmetic on in constant time
|
|
||||||
std::random_access_iterator_tag) {
|
|
||||||
unsigned NumArgs = (unsigned)std::distance(ArgBegin, ArgEnd);
|
|
||||||
|
|
||||||
// This requires that the iterator points to contiguous memory.
|
|
||||||
init(Func, NumArgs ? &*ArgBegin : 0, NumArgs);
|
|
||||||
setName(NameStr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Construct a CallInst given a range of arguments. RandomAccessIterator
|
|
||||||
/// 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
|
/// @brief Construct a CallInst from a range of arguments
|
||||||
template<typename RandomAccessIterator>
|
inline CallInst(Value *Func, ArrayRef<Value *> Args,
|
||||||
CallInst(Value *Func,
|
const Twine &NameStr, Instruction *InsertBefore);
|
||||||
RandomAccessIterator ArgBegin, RandomAccessIterator ArgEnd,
|
|
||||||
const Twine &NameStr, Instruction *InsertBefore);
|
|
||||||
|
|
||||||
/// Construct a CallInst given a range of arguments. RandomAccessIterator
|
/// Construct a CallInst given a range of arguments.
|
||||||
/// 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
|
/// @brief Construct a CallInst from a range of arguments
|
||||||
template<typename RandomAccessIterator>
|
inline CallInst(Value *Func, ArrayRef<Value *> Args,
|
||||||
inline CallInst(Value *Func,
|
|
||||||
RandomAccessIterator ArgBegin, RandomAccessIterator ArgEnd,
|
|
||||||
const Twine &NameStr, BasicBlock *InsertAtEnd);
|
const Twine &NameStr, BasicBlock *InsertAtEnd);
|
||||||
|
|
||||||
CallInst(Value *F, Value *Actual, const Twine &NameStr,
|
CallInst(Value *F, Value *Actual, const Twine &NameStr,
|
||||||
@ -894,31 +865,18 @@ class CallInst : public Instruction {
|
|||||||
protected:
|
protected:
|
||||||
virtual CallInst *clone_impl() const;
|
virtual CallInst *clone_impl() const;
|
||||||
public:
|
public:
|
||||||
template<typename RandomAccessIterator>
|
|
||||||
static CallInst *Create(Value *Func,
|
static CallInst *Create(Value *Func,
|
||||||
RandomAccessIterator ArgBegin,
|
ArrayRef<Value *> Args,
|
||||||
RandomAccessIterator ArgEnd,
|
|
||||||
const Twine &NameStr = "",
|
const Twine &NameStr = "",
|
||||||
Instruction *InsertBefore = 0) {
|
Instruction *InsertBefore = 0) {
|
||||||
return new(unsigned(ArgEnd - ArgBegin + 1))
|
return new(unsigned(Args.size() + 1))
|
||||||
CallInst(Func, ArgBegin, ArgEnd, NameStr, InsertBefore);
|
CallInst(Func, Args, NameStr, InsertBefore);
|
||||||
}
|
}
|
||||||
template<typename RandomAccessIterator>
|
|
||||||
static CallInst *Create(Value *Func,
|
static CallInst *Create(Value *Func,
|
||||||
RandomAccessIterator ArgBegin,
|
ArrayRef<Value *> Args,
|
||||||
RandomAccessIterator ArgEnd,
|
|
||||||
const Twine &NameStr, BasicBlock *InsertAtEnd) {
|
const Twine &NameStr, BasicBlock *InsertAtEnd) {
|
||||||
return new(unsigned(ArgEnd - ArgBegin + 1))
|
return new(unsigned(Args.size() + 1))
|
||||||
CallInst(Func, ArgBegin, ArgEnd, NameStr, InsertAtEnd);
|
CallInst(Func, Args, NameStr, InsertAtEnd);
|
||||||
}
|
|
||||||
static CallInst *Create(Value *F, Value *Actual,
|
|
||||||
const Twine &NameStr = "",
|
|
||||||
Instruction *InsertBefore = 0) {
|
|
||||||
return new(2) CallInst(F, Actual, NameStr, InsertBefore);
|
|
||||||
}
|
|
||||||
static CallInst *Create(Value *F, Value *Actual, const Twine &NameStr,
|
|
||||||
BasicBlock *InsertAtEnd) {
|
|
||||||
return new(2) CallInst(F, Actual, NameStr, InsertAtEnd);
|
|
||||||
}
|
}
|
||||||
static CallInst *Create(Value *F, const Twine &NameStr = "",
|
static CallInst *Create(Value *F, const Twine &NameStr = "",
|
||||||
Instruction *InsertBefore = 0) {
|
Instruction *InsertBefore = 0) {
|
||||||
@ -1093,32 +1051,24 @@ template <>
|
|||||||
struct OperandTraits<CallInst> : public VariadicOperandTraits<CallInst, 1> {
|
struct OperandTraits<CallInst> : public VariadicOperandTraits<CallInst, 1> {
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename RandomAccessIterator>
|
CallInst::CallInst(Value *Func, ArrayRef<Value *> Args,
|
||||||
CallInst::CallInst(Value *Func,
|
|
||||||
RandomAccessIterator ArgBegin, RandomAccessIterator ArgEnd,
|
|
||||||
const Twine &NameStr, BasicBlock *InsertAtEnd)
|
const Twine &NameStr, BasicBlock *InsertAtEnd)
|
||||||
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
|
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
|
||||||
->getElementType())->getReturnType(),
|
->getElementType())->getReturnType(),
|
||||||
Instruction::Call,
|
Instruction::Call,
|
||||||
OperandTraits<CallInst>::op_end(this) - (ArgEnd - ArgBegin + 1),
|
OperandTraits<CallInst>::op_end(this) - (Args.size() + 1),
|
||||||
unsigned(ArgEnd - ArgBegin + 1), InsertAtEnd) {
|
unsigned(Args.size() + 1), InsertAtEnd) {
|
||||||
init(Func, ArgBegin, ArgEnd, NameStr,
|
init(Func, Args, NameStr);
|
||||||
typename std::iterator_traits<RandomAccessIterator>
|
|
||||||
::iterator_category());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename RandomAccessIterator>
|
CallInst::CallInst(Value *Func, ArrayRef<Value *> Args,
|
||||||
CallInst::CallInst(Value *Func,
|
|
||||||
RandomAccessIterator ArgBegin, RandomAccessIterator ArgEnd,
|
|
||||||
const Twine &NameStr, Instruction *InsertBefore)
|
const Twine &NameStr, Instruction *InsertBefore)
|
||||||
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
|
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
|
||||||
->getElementType())->getReturnType(),
|
->getElementType())->getReturnType(),
|
||||||
Instruction::Call,
|
Instruction::Call,
|
||||||
OperandTraits<CallInst>::op_end(this) - (ArgEnd - ArgBegin + 1),
|
OperandTraits<CallInst>::op_end(this) - (Args.size() + 1),
|
||||||
unsigned(ArgEnd - ArgBegin + 1), InsertBefore) {
|
unsigned(Args.size() + 1), InsertBefore) {
|
||||||
init(Func, ArgBegin, ArgEnd, NameStr,
|
init(Func, Args, NameStr);
|
||||||
typename std::iterator_traits<RandomAccessIterator>
|
|
||||||
::iterator_category());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2282,71 +2232,39 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(IndirectBrInst, Value)
|
|||||||
class InvokeInst : public TerminatorInst {
|
class InvokeInst : public TerminatorInst {
|
||||||
AttrListPtr AttributeList;
|
AttrListPtr AttributeList;
|
||||||
InvokeInst(const InvokeInst &BI);
|
InvokeInst(const InvokeInst &BI);
|
||||||
void init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
|
|
||||||
Value* const *Args, unsigned NumArgs);
|
|
||||||
|
|
||||||
template<typename RandomAccessIterator>
|
|
||||||
void init(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
|
void init(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
|
||||||
RandomAccessIterator ArgBegin, RandomAccessIterator ArgEnd,
|
ArrayRef<Value *> Args, const Twine &NameStr);
|
||||||
const Twine &NameStr,
|
|
||||||
// This argument ensures that we have an iterator we can
|
|
||||||
// do arithmetic on in constant time
|
|
||||||
std::random_access_iterator_tag) {
|
|
||||||
unsigned NumArgs = (unsigned)std::distance(ArgBegin, ArgEnd);
|
|
||||||
|
|
||||||
// This requires that the iterator points to contiguous memory.
|
|
||||||
init(Func, IfNormal, IfException, NumArgs ? &*ArgBegin : 0, NumArgs);
|
|
||||||
setName(NameStr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Construct an InvokeInst given a range of arguments.
|
/// Construct an InvokeInst given a range of arguments.
|
||||||
/// RandomAccessIterator 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 an InvokeInst from a range of arguments
|
/// @brief Construct an InvokeInst from a range of arguments
|
||||||
template<typename RandomAccessIterator>
|
|
||||||
inline InvokeInst(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
|
inline InvokeInst(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
|
||||||
RandomAccessIterator ArgBegin, RandomAccessIterator ArgEnd,
|
ArrayRef<Value *> Args, unsigned Values,
|
||||||
unsigned Values,
|
|
||||||
const Twine &NameStr, Instruction *InsertBefore);
|
const Twine &NameStr, Instruction *InsertBefore);
|
||||||
|
|
||||||
/// Construct an InvokeInst given a range of arguments.
|
/// Construct an InvokeInst given a range of arguments.
|
||||||
/// RandomAccessIterator 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 an InvokeInst from a range of arguments
|
/// @brief Construct an InvokeInst from a range of arguments
|
||||||
template<typename RandomAccessIterator>
|
|
||||||
inline InvokeInst(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
|
inline InvokeInst(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
|
||||||
RandomAccessIterator ArgBegin, RandomAccessIterator ArgEnd,
|
ArrayRef<Value *> Args, unsigned Values,
|
||||||
unsigned Values,
|
|
||||||
const Twine &NameStr, BasicBlock *InsertAtEnd);
|
const Twine &NameStr, BasicBlock *InsertAtEnd);
|
||||||
protected:
|
protected:
|
||||||
virtual InvokeInst *clone_impl() const;
|
virtual InvokeInst *clone_impl() const;
|
||||||
public:
|
public:
|
||||||
template<typename RandomAccessIterator>
|
|
||||||
static InvokeInst *Create(Value *Func,
|
static InvokeInst *Create(Value *Func,
|
||||||
BasicBlock *IfNormal, BasicBlock *IfException,
|
BasicBlock *IfNormal, BasicBlock *IfException,
|
||||||
RandomAccessIterator ArgBegin,
|
ArrayRef<Value *> Args, const Twine &NameStr = "",
|
||||||
RandomAccessIterator ArgEnd,
|
|
||||||
const Twine &NameStr = "",
|
|
||||||
Instruction *InsertBefore = 0) {
|
Instruction *InsertBefore = 0) {
|
||||||
unsigned Values(ArgEnd - ArgBegin + 3);
|
unsigned Values = unsigned(Args.size()) + 3;
|
||||||
return new(Values) InvokeInst(Func, IfNormal, IfException, ArgBegin, ArgEnd,
|
return new(Values) InvokeInst(Func, IfNormal, IfException, Args,
|
||||||
Values, NameStr, InsertBefore);
|
Values, NameStr, InsertBefore);
|
||||||
}
|
}
|
||||||
template<typename RandomAccessIterator>
|
|
||||||
static InvokeInst *Create(Value *Func,
|
static InvokeInst *Create(Value *Func,
|
||||||
BasicBlock *IfNormal, BasicBlock *IfException,
|
BasicBlock *IfNormal, BasicBlock *IfException,
|
||||||
RandomAccessIterator ArgBegin,
|
ArrayRef<Value *> Args, const Twine &NameStr,
|
||||||
RandomAccessIterator ArgEnd,
|
|
||||||
const Twine &NameStr,
|
|
||||||
BasicBlock *InsertAtEnd) {
|
BasicBlock *InsertAtEnd) {
|
||||||
unsigned Values(ArgEnd - ArgBegin + 3);
|
unsigned Values = unsigned(Args.size()) + 3;
|
||||||
return new(Values) InvokeInst(Func, IfNormal, IfException, ArgBegin, ArgEnd,
|
return new(Values) InvokeInst(Func, IfNormal, IfException, Args,
|
||||||
Values, NameStr, InsertAtEnd);
|
Values, NameStr, InsertAtEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2512,37 +2430,27 @@ template <>
|
|||||||
struct OperandTraits<InvokeInst> : public VariadicOperandTraits<InvokeInst, 3> {
|
struct OperandTraits<InvokeInst> : public VariadicOperandTraits<InvokeInst, 3> {
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename RandomAccessIterator>
|
|
||||||
InvokeInst::InvokeInst(Value *Func,
|
InvokeInst::InvokeInst(Value *Func,
|
||||||
BasicBlock *IfNormal, BasicBlock *IfException,
|
BasicBlock *IfNormal, BasicBlock *IfException,
|
||||||
RandomAccessIterator ArgBegin,
|
ArrayRef<Value *> Args, unsigned Values,
|
||||||
RandomAccessIterator ArgEnd,
|
|
||||||
unsigned Values,
|
|
||||||
const Twine &NameStr, Instruction *InsertBefore)
|
const Twine &NameStr, Instruction *InsertBefore)
|
||||||
: TerminatorInst(cast<FunctionType>(cast<PointerType>(Func->getType())
|
: TerminatorInst(cast<FunctionType>(cast<PointerType>(Func->getType())
|
||||||
->getElementType())->getReturnType(),
|
->getElementType())->getReturnType(),
|
||||||
Instruction::Invoke,
|
Instruction::Invoke,
|
||||||
OperandTraits<InvokeInst>::op_end(this) - Values,
|
OperandTraits<InvokeInst>::op_end(this) - Values,
|
||||||
Values, InsertBefore) {
|
Values, InsertBefore) {
|
||||||
init(Func, IfNormal, IfException, ArgBegin, ArgEnd, NameStr,
|
init(Func, IfNormal, IfException, Args, NameStr);
|
||||||
typename std::iterator_traits<RandomAccessIterator>
|
|
||||||
::iterator_category());
|
|
||||||
}
|
}
|
||||||
template<typename RandomAccessIterator>
|
|
||||||
InvokeInst::InvokeInst(Value *Func,
|
InvokeInst::InvokeInst(Value *Func,
|
||||||
BasicBlock *IfNormal, BasicBlock *IfException,
|
BasicBlock *IfNormal, BasicBlock *IfException,
|
||||||
RandomAccessIterator ArgBegin,
|
ArrayRef<Value *> Args, unsigned Values,
|
||||||
RandomAccessIterator ArgEnd,
|
|
||||||
unsigned Values,
|
|
||||||
const Twine &NameStr, BasicBlock *InsertAtEnd)
|
const Twine &NameStr, BasicBlock *InsertAtEnd)
|
||||||
: TerminatorInst(cast<FunctionType>(cast<PointerType>(Func->getType())
|
: TerminatorInst(cast<FunctionType>(cast<PointerType>(Func->getType())
|
||||||
->getElementType())->getReturnType(),
|
->getElementType())->getReturnType(),
|
||||||
Instruction::Invoke,
|
Instruction::Invoke,
|
||||||
OperandTraits<InvokeInst>::op_end(this) - Values,
|
OperandTraits<InvokeInst>::op_end(this) - Values,
|
||||||
Values, InsertAtEnd) {
|
Values, InsertAtEnd) {
|
||||||
init(Func, IfNormal, IfException, ArgBegin, ArgEnd, NameStr,
|
init(Func, IfNormal, IfException, Args, NameStr);
|
||||||
typename std::iterator_traits<RandomAccessIterator>
|
|
||||||
::iterator_category());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(InvokeInst, Value)
|
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(InvokeInst, Value)
|
||||||
|
@ -449,34 +449,30 @@ public:
|
|||||||
|
|
||||||
InvokeInst *CreateInvoke(Value *Callee, BasicBlock *NormalDest,
|
InvokeInst *CreateInvoke(Value *Callee, BasicBlock *NormalDest,
|
||||||
BasicBlock *UnwindDest, const Twine &Name = "") {
|
BasicBlock *UnwindDest, const Twine &Name = "") {
|
||||||
Value *Args[] = { 0 };
|
return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest,
|
||||||
return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest, Args,
|
ArrayRef<Value *>()),
|
||||||
Args), Name);
|
Name);
|
||||||
}
|
}
|
||||||
InvokeInst *CreateInvoke(Value *Callee, BasicBlock *NormalDest,
|
InvokeInst *CreateInvoke(Value *Callee, BasicBlock *NormalDest,
|
||||||
BasicBlock *UnwindDest, Value *Arg1,
|
BasicBlock *UnwindDest, Value *Arg1,
|
||||||
const Twine &Name = "") {
|
const Twine &Name = "") {
|
||||||
Value *Args[] = { Arg1 };
|
return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest, Arg1),
|
||||||
return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest, Args,
|
Name);
|
||||||
Args+1), Name);
|
|
||||||
}
|
}
|
||||||
InvokeInst *CreateInvoke3(Value *Callee, BasicBlock *NormalDest,
|
InvokeInst *CreateInvoke3(Value *Callee, BasicBlock *NormalDest,
|
||||||
BasicBlock *UnwindDest, Value *Arg1,
|
BasicBlock *UnwindDest, Value *Arg1,
|
||||||
Value *Arg2, Value *Arg3,
|
Value *Arg2, Value *Arg3,
|
||||||
const Twine &Name = "") {
|
const Twine &Name = "") {
|
||||||
Value *Args[] = { Arg1, Arg2, Arg3 };
|
Value *Args[] = { Arg1, Arg2, Arg3 };
|
||||||
return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest, Args,
|
return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest, Args),
|
||||||
Args+3), Name);
|
Name);
|
||||||
}
|
}
|
||||||
/// CreateInvoke - Create an invoke instruction.
|
/// CreateInvoke - Create an invoke instruction.
|
||||||
template<typename RandomAccessIterator>
|
|
||||||
InvokeInst *CreateInvoke(Value *Callee, BasicBlock *NormalDest,
|
InvokeInst *CreateInvoke(Value *Callee, BasicBlock *NormalDest,
|
||||||
BasicBlock *UnwindDest,
|
BasicBlock *UnwindDest, ArrayRef<Value *> Args,
|
||||||
RandomAccessIterator ArgBegin,
|
|
||||||
RandomAccessIterator ArgEnd,
|
|
||||||
const Twine &Name = "") {
|
const Twine &Name = "") {
|
||||||
return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest,
|
return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest, Args),
|
||||||
ArgBegin, ArgEnd), Name);
|
Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
UnwindInst *CreateUnwind() {
|
UnwindInst *CreateUnwind() {
|
||||||
@ -1126,33 +1122,27 @@ public:
|
|||||||
CallInst *CreateCall2(Value *Callee, Value *Arg1, Value *Arg2,
|
CallInst *CreateCall2(Value *Callee, Value *Arg1, Value *Arg2,
|
||||||
const Twine &Name = "") {
|
const Twine &Name = "") {
|
||||||
Value *Args[] = { Arg1, Arg2 };
|
Value *Args[] = { Arg1, Arg2 };
|
||||||
return Insert(CallInst::Create(Callee, Args, Args+2), Name);
|
return Insert(CallInst::Create(Callee, Args), Name);
|
||||||
}
|
}
|
||||||
CallInst *CreateCall3(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3,
|
CallInst *CreateCall3(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3,
|
||||||
const Twine &Name = "") {
|
const Twine &Name = "") {
|
||||||
Value *Args[] = { Arg1, Arg2, Arg3 };
|
Value *Args[] = { Arg1, Arg2, Arg3 };
|
||||||
return Insert(CallInst::Create(Callee, Args, Args+3), Name);
|
return Insert(CallInst::Create(Callee, Args), Name);
|
||||||
}
|
}
|
||||||
CallInst *CreateCall4(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3,
|
CallInst *CreateCall4(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3,
|
||||||
Value *Arg4, const Twine &Name = "") {
|
Value *Arg4, const Twine &Name = "") {
|
||||||
Value *Args[] = { Arg1, Arg2, Arg3, Arg4 };
|
Value *Args[] = { Arg1, Arg2, Arg3, Arg4 };
|
||||||
return Insert(CallInst::Create(Callee, Args, Args+4), Name);
|
return Insert(CallInst::Create(Callee, Args), Name);
|
||||||
}
|
}
|
||||||
CallInst *CreateCall5(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3,
|
CallInst *CreateCall5(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3,
|
||||||
Value *Arg4, Value *Arg5, const Twine &Name = "") {
|
Value *Arg4, Value *Arg5, const Twine &Name = "") {
|
||||||
Value *Args[] = { Arg1, Arg2, Arg3, Arg4, Arg5 };
|
Value *Args[] = { Arg1, Arg2, Arg3, Arg4, Arg5 };
|
||||||
return Insert(CallInst::Create(Callee, Args, Args+5), Name);
|
return Insert(CallInst::Create(Callee, Args), Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
CallInst *CreateCall(Value *Callee, ArrayRef<Value *> Arg,
|
CallInst *CreateCall(Value *Callee, ArrayRef<Value *> Args,
|
||||||
const Twine &Name = "") {
|
const Twine &Name = "") {
|
||||||
return Insert(CallInst::Create(Callee, Arg.begin(), Arg.end(), Name));
|
return Insert(CallInst::Create(Callee, Args, Name));
|
||||||
}
|
|
||||||
|
|
||||||
template<typename RandomAccessIterator>
|
|
||||||
CallInst *CreateCall(Value *Callee, RandomAccessIterator ArgBegin,
|
|
||||||
RandomAccessIterator ArgEnd, const Twine &Name = "") {
|
|
||||||
return Insert(CallInst::Create(Callee, ArgBegin, ArgEnd), Name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value *CreateSelect(Value *C, Value *True, Value *False,
|
Value *CreateSelect(Value *C, Value *True, Value *False,
|
||||||
|
@ -786,7 +786,7 @@ Instruction *DIBuilder::insertDeclare(Value *Storage, DIVariable VarInfo,
|
|||||||
DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare);
|
DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare);
|
||||||
|
|
||||||
Value *Args[] = { MDNode::get(Storage->getContext(), Storage), VarInfo };
|
Value *Args[] = { MDNode::get(Storage->getContext(), Storage), VarInfo };
|
||||||
return CallInst::Create(DeclareFn, Args, Args+2, "", InsertBefore);
|
return CallInst::Create(DeclareFn, Args, "", InsertBefore);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
|
/// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
|
||||||
@ -802,9 +802,9 @@ Instruction *DIBuilder::insertDeclare(Value *Storage, DIVariable VarInfo,
|
|||||||
// If this block already has a terminator then insert this intrinsic
|
// If this block already has a terminator then insert this intrinsic
|
||||||
// before the terminator.
|
// before the terminator.
|
||||||
if (TerminatorInst *T = InsertAtEnd->getTerminator())
|
if (TerminatorInst *T = InsertAtEnd->getTerminator())
|
||||||
return CallInst::Create(DeclareFn, Args, Args+2, "", T);
|
return CallInst::Create(DeclareFn, Args, "", T);
|
||||||
else
|
else
|
||||||
return CallInst::Create(DeclareFn, Args, Args+2, "", InsertAtEnd);
|
return CallInst::Create(DeclareFn, Args, "", InsertAtEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
|
/// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
|
||||||
@ -819,7 +819,7 @@ Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset,
|
|||||||
Value *Args[] = { MDNode::get(V->getContext(), V),
|
Value *Args[] = { MDNode::get(V->getContext(), V),
|
||||||
ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset),
|
ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset),
|
||||||
VarInfo };
|
VarInfo };
|
||||||
return CallInst::Create(ValueFn, Args, Args+3, "", InsertBefore);
|
return CallInst::Create(ValueFn, Args, "", InsertBefore);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
|
/// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
|
||||||
@ -834,6 +834,6 @@ Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset,
|
|||||||
Value *Args[] = { MDNode::get(V->getContext(), V),
|
Value *Args[] = { MDNode::get(V->getContext(), V),
|
||||||
ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset),
|
ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset),
|
||||||
VarInfo };
|
VarInfo };
|
||||||
return CallInst::Create(ValueFn, Args, Args+3, "", InsertAtEnd);
|
return CallInst::Create(ValueFn, Args, "", InsertAtEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3218,8 +3218,7 @@ bool LLParser::ParseInvoke(Instruction *&Inst, PerFunctionState &PFS) {
|
|||||||
// Finish off the Attributes and check them
|
// Finish off the Attributes and check them
|
||||||
AttrListPtr PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
|
AttrListPtr PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
|
||||||
|
|
||||||
InvokeInst *II = InvokeInst::Create(Callee, NormalBB, UnwindBB,
|
InvokeInst *II = InvokeInst::Create(Callee, NormalBB, UnwindBB, Args);
|
||||||
Args.begin(), Args.end());
|
|
||||||
II->setCallingConv(CC);
|
II->setCallingConv(CC);
|
||||||
II->setAttributes(PAL);
|
II->setAttributes(PAL);
|
||||||
Inst = II;
|
Inst = II;
|
||||||
@ -3555,7 +3554,7 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS,
|
|||||||
// Finish off the Attributes and check them
|
// Finish off the Attributes and check them
|
||||||
AttrListPtr PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
|
AttrListPtr PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
|
||||||
|
|
||||||
CallInst *CI = CallInst::Create(Callee, Args.begin(), Args.end());
|
CallInst *CI = CallInst::Create(Callee, Args);
|
||||||
CI->setTailCall(isTail);
|
CI->setTailCall(isTail);
|
||||||
CI->setCallingConv(CC);
|
CI->setCallingConv(CC);
|
||||||
CI->setAttributes(PAL);
|
CI->setAttributes(PAL);
|
||||||
|
@ -2465,8 +2465,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
I = InvokeInst::Create(Callee, NormalBB, UnwindBB,
|
I = InvokeInst::Create(Callee, NormalBB, UnwindBB, Ops);
|
||||||
Ops.begin(), Ops.end());
|
|
||||||
InstructionList.push_back(I);
|
InstructionList.push_back(I);
|
||||||
cast<InvokeInst>(I)->setCallingConv(
|
cast<InvokeInst>(I)->setCallingConv(
|
||||||
static_cast<CallingConv::ID>(CCInfo));
|
static_cast<CallingConv::ID>(CCInfo));
|
||||||
@ -2579,7 +2578,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
I = CallInst::Create(Callee, Args.begin(), Args.end());
|
I = CallInst::Create(Callee, Args);
|
||||||
InstructionList.push_back(I);
|
InstructionList.push_back(I);
|
||||||
cast<CallInst>(I)->setCallingConv(
|
cast<CallInst>(I)->setCallingConv(
|
||||||
static_cast<CallingConv::ID>(CCInfo>>1));
|
static_cast<CallingConv::ID>(CCInfo>>1));
|
||||||
|
@ -336,8 +336,7 @@ bool DwarfEHPrepare::HandleURoRInvokes() {
|
|||||||
Args.push_back(EHCatchAllValue->getInitializer()); // Catch-all indicator.
|
Args.push_back(EHCatchAllValue->getInitializer()); // Catch-all indicator.
|
||||||
|
|
||||||
CallInst *NewSelector =
|
CallInst *NewSelector =
|
||||||
CallInst::Create(SelectorIntrinsic, Args.begin(), Args.end(),
|
CallInst::Create(SelectorIntrinsic, Args, "eh.sel.catch.all", II);
|
||||||
"eh.sel.catch.all", II);
|
|
||||||
|
|
||||||
NewSelector->setTailCall(II->isTailCall());
|
NewSelector->setTailCall(II->isTailCall());
|
||||||
NewSelector->setAttributes(II->getAttributes());
|
NewSelector->setAttributes(II->getAttributes());
|
||||||
|
@ -77,7 +77,7 @@ static CallInst *ReplaceCallWith(const char *NewFn, CallInst *CI,
|
|||||||
|
|
||||||
IRBuilder<> Builder(CI->getParent(), CI);
|
IRBuilder<> Builder(CI->getParent(), CI);
|
||||||
SmallVector<Value *, 8> Args(ArgBegin, ArgEnd);
|
SmallVector<Value *, 8> Args(ArgBegin, ArgEnd);
|
||||||
CallInst *NewCI = Builder.CreateCall(FCache, Args.begin(), Args.end());
|
CallInst *NewCI = Builder.CreateCall(FCache, Args);
|
||||||
NewCI->setName(CI->getName());
|
NewCI->setName(CI->getName());
|
||||||
if (!CI->use_empty())
|
if (!CI->use_empty())
|
||||||
CI->replaceAllUsesWith(NewCI);
|
CI->replaceAllUsesWith(NewCI);
|
||||||
|
@ -165,8 +165,7 @@ namespace {
|
|||||||
|
|
||||||
InvokeInst *II = InvokeInst::Create(CI->getCalledValue(),
|
InvokeInst *II = InvokeInst::Create(CI->getCalledValue(),
|
||||||
NewBB, CleanupBB,
|
NewBB, CleanupBB,
|
||||||
Args.begin(), Args.end(),
|
Args, CI->getName(), CallBB);
|
||||||
CI->getName(), CallBB);
|
|
||||||
II->setCallingConv(CI->getCallingConv());
|
II->setCallingConv(CI->getCallingConv());
|
||||||
II->setAttributes(CI->getAttributes());
|
II->setAttributes(CI->getAttributes());
|
||||||
CI->replaceAllUsesWith(II);
|
CI->replaceAllUsesWith(II);
|
||||||
|
@ -186,7 +186,7 @@ bool StackProtector::InsertStackProtectors() {
|
|||||||
Value *Args[] = { LI, AI };
|
Value *Args[] = { LI, AI };
|
||||||
CallInst::
|
CallInst::
|
||||||
Create(Intrinsic::getDeclaration(M, Intrinsic::stackprotector),
|
Create(Intrinsic::getDeclaration(M, Intrinsic::stackprotector),
|
||||||
&Args[0], array_endof(Args), "", InsPt);
|
Args, "", InsPt);
|
||||||
|
|
||||||
// Create the basic block to jump to when the guard check fails.
|
// Create the basic block to jump to when the guard check fails.
|
||||||
FailBB = CreateFailBB();
|
FailBB = CreateFailBB();
|
||||||
|
@ -533,8 +533,7 @@ GenericValue JIT::runFunction(Function *F,
|
|||||||
Args.push_back(C);
|
Args.push_back(C);
|
||||||
}
|
}
|
||||||
|
|
||||||
CallInst *TheCall = CallInst::Create(F, Args.begin(), Args.end(),
|
CallInst *TheCall = CallInst::Create(F, Args, "", StubBB);
|
||||||
"", StubBB);
|
|
||||||
TheCall->setCallingConv(F->getCallingConv());
|
TheCall->setCallingConv(F->getCallingConv());
|
||||||
TheCall->setTailCall();
|
TheCall->setTailCall();
|
||||||
if (!TheCall->getType()->isVoidTy())
|
if (!TheCall->getType()->isVoidTy())
|
||||||
|
@ -733,12 +733,12 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
|
|||||||
Instruction *New;
|
Instruction *New;
|
||||||
if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {
|
if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {
|
||||||
New = InvokeInst::Create(NF, II->getNormalDest(), II->getUnwindDest(),
|
New = InvokeInst::Create(NF, II->getNormalDest(), II->getUnwindDest(),
|
||||||
Args.begin(), Args.end(), "", Call);
|
Args, "", Call);
|
||||||
cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
|
cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
|
||||||
cast<InvokeInst>(New)->setAttributes(AttrListPtr::get(AttributesVec.begin(),
|
cast<InvokeInst>(New)->setAttributes(AttrListPtr::get(AttributesVec.begin(),
|
||||||
AttributesVec.end()));
|
AttributesVec.end()));
|
||||||
} else {
|
} else {
|
||||||
New = CallInst::Create(NF, Args.begin(), Args.end(), "", Call);
|
New = CallInst::Create(NF, Args, "", Call);
|
||||||
cast<CallInst>(New)->setCallingConv(CS.getCallingConv());
|
cast<CallInst>(New)->setCallingConv(CS.getCallingConv());
|
||||||
cast<CallInst>(New)->setAttributes(AttrListPtr::get(AttributesVec.begin(),
|
cast<CallInst>(New)->setAttributes(AttrListPtr::get(AttributesVec.begin(),
|
||||||
AttributesVec.end()));
|
AttributesVec.end()));
|
||||||
|
@ -244,11 +244,11 @@ bool DAE::DeleteDeadVarargs(Function &Fn) {
|
|||||||
Instruction *New;
|
Instruction *New;
|
||||||
if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {
|
if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {
|
||||||
New = InvokeInst::Create(NF, II->getNormalDest(), II->getUnwindDest(),
|
New = InvokeInst::Create(NF, II->getNormalDest(), II->getUnwindDest(),
|
||||||
Args.begin(), Args.end(), "", Call);
|
Args, "", Call);
|
||||||
cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
|
cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
|
||||||
cast<InvokeInst>(New)->setAttributes(PAL);
|
cast<InvokeInst>(New)->setAttributes(PAL);
|
||||||
} else {
|
} else {
|
||||||
New = CallInst::Create(NF, Args.begin(), Args.end(), "", Call);
|
New = CallInst::Create(NF, Args, "", Call);
|
||||||
cast<CallInst>(New)->setCallingConv(CS.getCallingConv());
|
cast<CallInst>(New)->setCallingConv(CS.getCallingConv());
|
||||||
cast<CallInst>(New)->setAttributes(PAL);
|
cast<CallInst>(New)->setAttributes(PAL);
|
||||||
if (cast<CallInst>(Call)->isTailCall())
|
if (cast<CallInst>(Call)->isTailCall())
|
||||||
@ -822,11 +822,11 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
|
|||||||
Instruction *New;
|
Instruction *New;
|
||||||
if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {
|
if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {
|
||||||
New = InvokeInst::Create(NF, II->getNormalDest(), II->getUnwindDest(),
|
New = InvokeInst::Create(NF, II->getNormalDest(), II->getUnwindDest(),
|
||||||
Args.begin(), Args.end(), "", Call);
|
Args, "", Call);
|
||||||
cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
|
cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
|
||||||
cast<InvokeInst>(New)->setAttributes(NewCallPAL);
|
cast<InvokeInst>(New)->setAttributes(NewCallPAL);
|
||||||
} else {
|
} else {
|
||||||
New = CallInst::Create(NF, Args.begin(), Args.end(), "", Call);
|
New = CallInst::Create(NF, Args, "", Call);
|
||||||
cast<CallInst>(New)->setCallingConv(CS.getCallingConv());
|
cast<CallInst>(New)->setCallingConv(CS.getCallingConv());
|
||||||
cast<CallInst>(New)->setAttributes(NewCallPAL);
|
cast<CallInst>(New)->setAttributes(NewCallPAL);
|
||||||
if (cast<CallInst>(Call)->isTailCall())
|
if (cast<CallInst>(Call)->isTailCall())
|
||||||
|
@ -267,7 +267,7 @@ void LowerSetJmp::TransformLongJmpCall(CallInst* Inst)
|
|||||||
CastInst* CI =
|
CastInst* CI =
|
||||||
new BitCastInst(Inst->getArgOperand(0), SBPTy, "LJBuf", Inst);
|
new BitCastInst(Inst->getArgOperand(0), SBPTy, "LJBuf", Inst);
|
||||||
Value *Args[] = { CI, Inst->getArgOperand(1) };
|
Value *Args[] = { CI, Inst->getArgOperand(1) };
|
||||||
CallInst::Create(ThrowLongJmp, Args, Args + 2, "", Inst);
|
CallInst::Create(ThrowLongJmp, Args, "", Inst);
|
||||||
|
|
||||||
SwitchValuePair& SVP = SwitchValMap[Inst->getParent()->getParent()];
|
SwitchValuePair& SVP = SwitchValMap[Inst->getParent()->getParent()];
|
||||||
|
|
||||||
@ -386,7 +386,7 @@ void LowerSetJmp::TransformSetJmpCall(CallInst* Inst)
|
|||||||
GetSetJmpMap(Func), BufPtr,
|
GetSetJmpMap(Func), BufPtr,
|
||||||
ConstantInt::get(Type::getInt32Ty(Inst->getContext()), SetJmpIDMap[Func]++)
|
ConstantInt::get(Type::getInt32Ty(Inst->getContext()), SetJmpIDMap[Func]++)
|
||||||
};
|
};
|
||||||
CallInst::Create(AddSJToMap, Args, Args + 3, "", Inst);
|
CallInst::Create(AddSJToMap, Args, "", Inst);
|
||||||
|
|
||||||
// We are guaranteed that there are no values live across basic blocks
|
// 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
|
// (because we are "not in SSA form" yet), but there can still be values live
|
||||||
@ -482,7 +482,7 @@ void LowerSetJmp::visitCallInst(CallInst& CI)
|
|||||||
std::vector<Value*> Params(CS.arg_begin(), CS.arg_end());
|
std::vector<Value*> Params(CS.arg_begin(), CS.arg_end());
|
||||||
InvokeInst* II =
|
InvokeInst* II =
|
||||||
InvokeInst::Create(CI.getCalledValue(), NewBB, PrelimBBMap[Func],
|
InvokeInst::Create(CI.getCalledValue(), NewBB, PrelimBBMap[Func],
|
||||||
Params.begin(), Params.end(), CI.getName(), Term);
|
Params, CI.getName(), Term);
|
||||||
II->setCallingConv(CI.getCallingConv());
|
II->setCallingConv(CI.getCallingConv());
|
||||||
II->setAttributes(CI.getAttributes());
|
II->setAttributes(CI.getAttributes());
|
||||||
|
|
||||||
|
@ -732,7 +732,7 @@ void MergeFunctions::writeThunk(Function *F, Function *G) {
|
|||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
CallInst *CI = Builder.CreateCall(F, Args.begin(), Args.end());
|
CallInst *CI = Builder.CreateCall(F, Args);
|
||||||
CI->setTailCall();
|
CI->setTailCall();
|
||||||
CI->setCallingConv(F->getCallingConv());
|
CI->setCallingConv(F->getCallingConv());
|
||||||
if (NewG->getReturnType()->isVoidTy()) {
|
if (NewG->getReturnType()->isVoidTy()) {
|
||||||
|
@ -175,8 +175,7 @@ bool PruneEH::SimplifyFunction(Function *F) {
|
|||||||
if (II->doesNotThrow()) {
|
if (II->doesNotThrow()) {
|
||||||
SmallVector<Value*, 8> Args(II->op_begin(), II->op_end() - 3);
|
SmallVector<Value*, 8> Args(II->op_begin(), II->op_end() - 3);
|
||||||
// Insert a call instruction before the invoke.
|
// Insert a call instruction before the invoke.
|
||||||
CallInst *Call = CallInst::Create(II->getCalledValue(),
|
CallInst *Call = CallInst::Create(II->getCalledValue(), Args, "", II);
|
||||||
Args.begin(), Args.end(), "", II);
|
|
||||||
Call->takeName(II);
|
Call->takeName(II);
|
||||||
Call->setCallingConv(II->getCallingConv());
|
Call->setCallingConv(II->getCallingConv());
|
||||||
Call->setAttributes(II->getAttributes());
|
Call->setAttributes(II->getAttributes());
|
||||||
|
@ -1118,13 +1118,13 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
|
|||||||
Instruction *NC;
|
Instruction *NC;
|
||||||
if (InvokeInst *II = dyn_cast<InvokeInst>(Caller)) {
|
if (InvokeInst *II = dyn_cast<InvokeInst>(Caller)) {
|
||||||
NC = Builder->CreateInvoke(Callee, II->getNormalDest(),
|
NC = Builder->CreateInvoke(Callee, II->getNormalDest(),
|
||||||
II->getUnwindDest(), Args.begin(), Args.end());
|
II->getUnwindDest(), Args);
|
||||||
NC->takeName(II);
|
NC->takeName(II);
|
||||||
cast<InvokeInst>(NC)->setCallingConv(II->getCallingConv());
|
cast<InvokeInst>(NC)->setCallingConv(II->getCallingConv());
|
||||||
cast<InvokeInst>(NC)->setAttributes(NewCallerPAL);
|
cast<InvokeInst>(NC)->setAttributes(NewCallerPAL);
|
||||||
} else {
|
} else {
|
||||||
CallInst *CI = cast<CallInst>(Caller);
|
CallInst *CI = cast<CallInst>(Caller);
|
||||||
NC = Builder->CreateCall(Callee, Args.begin(), Args.end());
|
NC = Builder->CreateCall(Callee, Args);
|
||||||
NC->takeName(CI);
|
NC->takeName(CI);
|
||||||
if (CI->isTailCall())
|
if (CI->isTailCall())
|
||||||
cast<CallInst>(NC)->setTailCall();
|
cast<CallInst>(NC)->setTailCall();
|
||||||
@ -1289,11 +1289,11 @@ Instruction *InstCombiner::transformCallThroughTrampoline(CallSite CS) {
|
|||||||
if (InvokeInst *II = dyn_cast<InvokeInst>(Caller)) {
|
if (InvokeInst *II = dyn_cast<InvokeInst>(Caller)) {
|
||||||
NewCaller = InvokeInst::Create(NewCallee,
|
NewCaller = InvokeInst::Create(NewCallee,
|
||||||
II->getNormalDest(), II->getUnwindDest(),
|
II->getNormalDest(), II->getUnwindDest(),
|
||||||
NewArgs.begin(), NewArgs.end());
|
NewArgs);
|
||||||
cast<InvokeInst>(NewCaller)->setCallingConv(II->getCallingConv());
|
cast<InvokeInst>(NewCaller)->setCallingConv(II->getCallingConv());
|
||||||
cast<InvokeInst>(NewCaller)->setAttributes(NewPAL);
|
cast<InvokeInst>(NewCaller)->setAttributes(NewPAL);
|
||||||
} else {
|
} else {
|
||||||
NewCaller = CallInst::Create(NewCallee, NewArgs.begin(), NewArgs.end());
|
NewCaller = CallInst::Create(NewCallee, NewArgs);
|
||||||
if (cast<CallInst>(Caller)->isTailCall())
|
if (cast<CallInst>(Caller)->isTailCall())
|
||||||
cast<CallInst>(NewCaller)->setTailCall();
|
cast<CallInst>(NewCaller)->setTailCall();
|
||||||
cast<CallInst>(NewCaller)->
|
cast<CallInst>(NewCaller)->
|
||||||
|
@ -1062,7 +1062,7 @@ void PathProfiler::insertCounterIncrement(Value* incValue,
|
|||||||
|
|
||||||
CallInst::Create(
|
CallInst::Create(
|
||||||
increment ? llvmIncrementHashFunction : llvmDecrementHashFunction,
|
increment ? llvmIncrementHashFunction : llvmDecrementHashFunction,
|
||||||
args.begin(), args.end(), "", insertPoint);
|
args, "", insertPoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,8 +62,7 @@ void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName,
|
|||||||
}
|
}
|
||||||
Args[3] = ConstantInt::get(Type::getInt32Ty(Context), NumElements);
|
Args[3] = ConstantInt::get(Type::getInt32Ty(Context), NumElements);
|
||||||
|
|
||||||
CallInst *InitCall = CallInst::Create(InitFn, Args.begin(), Args.end(),
|
CallInst *InitCall = CallInst::Create(InitFn, Args, "newargc", InsertPos);
|
||||||
"newargc", InsertPos);
|
|
||||||
|
|
||||||
// If argc or argv are not available in main, just pass null values in.
|
// If argc or argv are not available in main, just pass null values in.
|
||||||
Function::arg_iterator AI;
|
Function::arg_iterator AI;
|
||||||
|
@ -3421,7 +3421,7 @@ void ObjCARCContract::ContractRelease(Instruction *Release,
|
|||||||
Args[1] = new BitCastInst(Args[1], I8X, "", Store);
|
Args[1] = new BitCastInst(Args[1], I8X, "", Store);
|
||||||
CallInst *StoreStrong =
|
CallInst *StoreStrong =
|
||||||
CallInst::Create(getStoreStrongCallee(BB->getParent()->getParent()),
|
CallInst::Create(getStoreStrongCallee(BB->getParent()->getParent()),
|
||||||
Args, array_endof(Args), "", Store);
|
Args, "", Store);
|
||||||
StoreStrong->setDoesNotThrow();
|
StoreStrong->setDoesNotThrow();
|
||||||
StoreStrong->setDebugLoc(Store->getDebugLoc());
|
StoreStrong->setDebugLoc(Store->getDebugLoc());
|
||||||
|
|
||||||
|
@ -91,8 +91,7 @@ static void ChangeToUnreachable(Instruction *I, bool UseLLVMTrap) {
|
|||||||
static void ChangeToCall(InvokeInst *II) {
|
static void ChangeToCall(InvokeInst *II) {
|
||||||
BasicBlock *BB = II->getParent();
|
BasicBlock *BB = II->getParent();
|
||||||
SmallVector<Value*, 8> Args(II->op_begin(), II->op_end() - 3);
|
SmallVector<Value*, 8> Args(II->op_begin(), II->op_end() - 3);
|
||||||
CallInst *NewCall = CallInst::Create(II->getCalledValue(), Args.begin(),
|
CallInst *NewCall = CallInst::Create(II->getCalledValue(), Args, "", II);
|
||||||
Args.end(), "", II);
|
|
||||||
NewCall->takeName(II);
|
NewCall->takeName(II);
|
||||||
NewCall->setCallingConv(II->getCallingConv());
|
NewCall->setCallingConv(II->getCallingConv());
|
||||||
NewCall->setAttributes(II->getAttributes());
|
NewCall->setAttributes(II->getAttributes());
|
||||||
|
@ -429,7 +429,7 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Emit the call to the function
|
// Emit the call to the function
|
||||||
CallInst *call = CallInst::Create(newFunction, params.begin(), params.end(),
|
CallInst *call = CallInst::Create(newFunction, params,
|
||||||
NumExitBlocks > 1 ? "targetBlock" : "");
|
NumExitBlocks > 1 ? "targetBlock" : "");
|
||||||
codeReplacer->getInstList().push_back(call);
|
codeReplacer->getInstList().push_back(call);
|
||||||
|
|
||||||
|
@ -450,9 +450,7 @@ static bool HandleCallsInBlockInlinedThroughInvoke(BasicBlock *BB,
|
|||||||
NewSelector.push_back(Outer->getArgOperand(i));
|
NewSelector.push_back(Outer->getArgOperand(i));
|
||||||
|
|
||||||
CallInst *NewInner =
|
CallInst *NewInner =
|
||||||
IRBuilder<>(Inner).CreateCall(Inner->getCalledValue(),
|
IRBuilder<>(Inner).CreateCall(Inner->getCalledValue(), NewSelector);
|
||||||
NewSelector.begin(),
|
|
||||||
NewSelector.end());
|
|
||||||
// No need to copy attributes, calling convention, etc.
|
// No need to copy attributes, calling convention, etc.
|
||||||
NewInner->takeName(Inner);
|
NewInner->takeName(Inner);
|
||||||
Inner->replaceAllUsesWith(NewInner);
|
Inner->replaceAllUsesWith(NewInner);
|
||||||
@ -488,8 +486,7 @@ static bool HandleCallsInBlockInlinedThroughInvoke(BasicBlock *BB,
|
|||||||
InvokeInst *II =
|
InvokeInst *II =
|
||||||
InvokeInst::Create(CI->getCalledValue(), Split,
|
InvokeInst::Create(CI->getCalledValue(), Split,
|
||||||
Invoke.getOuterUnwindDest(),
|
Invoke.getOuterUnwindDest(),
|
||||||
InvokeArgs.begin(), InvokeArgs.end(),
|
InvokeArgs, CI->getName(), BB);
|
||||||
CI->getName(), BB);
|
|
||||||
II->setCallingConv(CI->getCallingConv());
|
II->setCallingConv(CI->getCallingConv());
|
||||||
II->setAttributes(CI->getAttributes());
|
II->setAttributes(CI->getAttributes());
|
||||||
|
|
||||||
@ -702,7 +699,7 @@ static Value *HandleByValArgument(Value *Arg, Instruction *TheCall,
|
|||||||
ConstantInt::get(Type::getInt32Ty(Context), 1),
|
ConstantInt::get(Type::getInt32Ty(Context), 1),
|
||||||
ConstantInt::getFalse(Context) // isVolatile
|
ConstantInt::getFalse(Context) // isVolatile
|
||||||
};
|
};
|
||||||
IRBuilder<>(TheCall).CreateCall(MemCpyFn, CallArgs, CallArgs+5);
|
IRBuilder<>(TheCall).CreateCall(MemCpyFn, CallArgs);
|
||||||
|
|
||||||
// Uses of the argument in the function should use our new alloca
|
// Uses of the argument in the function should use our new alloca
|
||||||
// instead.
|
// instead.
|
||||||
|
@ -176,8 +176,7 @@ bool LowerInvoke::insertCheapEHSupport(Function &F) {
|
|||||||
SmallVector<Value*,16> CallArgs(II->op_begin(), II->op_end() - 3);
|
SmallVector<Value*,16> CallArgs(II->op_begin(), II->op_end() - 3);
|
||||||
// Insert a normal call instruction...
|
// Insert a normal call instruction...
|
||||||
CallInst *NewCall = CallInst::Create(II->getCalledValue(),
|
CallInst *NewCall = CallInst::Create(II->getCalledValue(),
|
||||||
CallArgs.begin(), CallArgs.end(),
|
CallArgs, "", II);
|
||||||
"",II);
|
|
||||||
NewCall->takeName(II);
|
NewCall->takeName(II);
|
||||||
NewCall->setCallingConv(II->getCallingConv());
|
NewCall->setCallingConv(II->getCallingConv());
|
||||||
NewCall->setAttributes(II->getAttributes());
|
NewCall->setAttributes(II->getAttributes());
|
||||||
@ -257,8 +256,7 @@ void LowerInvoke::rewriteExpensiveInvoke(InvokeInst *II, unsigned InvokeNo,
|
|||||||
// Insert a normal call instruction.
|
// Insert a normal call instruction.
|
||||||
SmallVector<Value*,16> CallArgs(II->op_begin(), II->op_end() - 3);
|
SmallVector<Value*,16> CallArgs(II->op_begin(), II->op_end() - 3);
|
||||||
CallInst *NewCall = CallInst::Create(II->getCalledValue(),
|
CallInst *NewCall = CallInst::Create(II->getCalledValue(),
|
||||||
CallArgs.begin(), CallArgs.end(), "",
|
CallArgs, "", II);
|
||||||
II);
|
|
||||||
NewCall->takeName(II);
|
NewCall->takeName(II);
|
||||||
NewCall->setCallingConv(II->getCallingConv());
|
NewCall->setCallingConv(II->getCallingConv());
|
||||||
NewCall->setAttributes(II->getAttributes());
|
NewCall->setAttributes(II->getAttributes());
|
||||||
@ -565,7 +563,7 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
|
|||||||
Type::getInt8PtrTy(F.getContext()),
|
Type::getInt8PtrTy(F.getContext()),
|
||||||
"tmp", UnwindBlock);
|
"tmp", UnwindBlock);
|
||||||
Idx[1] = ConstantInt::get(Type::getInt32Ty(F.getContext()), 1);
|
Idx[1] = ConstantInt::get(Type::getInt32Ty(F.getContext()), 1);
|
||||||
CallInst::Create(LongJmpFn, &Idx[0], &Idx[2], "", UnwindBlock);
|
CallInst::Create(LongJmpFn, Idx, "", UnwindBlock);
|
||||||
new UnreachableInst(F.getContext(), UnwindBlock);
|
new UnreachableInst(F.getContext(), UnwindBlock);
|
||||||
|
|
||||||
// Set up the term block ("throw without a catch").
|
// Set up the term block ("throw without a catch").
|
||||||
|
@ -2211,8 +2211,7 @@ bool SimplifyCFGOpt::SimplifyUnwind(UnwindInst *UI, IRBuilder<> &Builder) {
|
|||||||
SmallVector<Value*,8> Args(II->op_begin(), II->op_end()-3);
|
SmallVector<Value*,8> Args(II->op_begin(), II->op_end()-3);
|
||||||
Builder.SetInsertPoint(BI);
|
Builder.SetInsertPoint(BI);
|
||||||
CallInst *CI = Builder.CreateCall(II->getCalledValue(),
|
CallInst *CI = Builder.CreateCall(II->getCalledValue(),
|
||||||
Args.begin(), Args.end(),
|
Args, II->getName());
|
||||||
II->getName());
|
|
||||||
CI->setCallingConv(II->getCallingConv());
|
CI->setCallingConv(II->getCallingConv());
|
||||||
CI->setAttributes(II->getAttributes());
|
CI->setAttributes(II->getAttributes());
|
||||||
// If the invoke produced a value, the Call now does instead.
|
// If the invoke produced a value, the Call now does instead.
|
||||||
@ -2355,8 +2354,7 @@ bool SimplifyCFGOpt::SimplifyUnreachable(UnreachableInst *UI) {
|
|||||||
SmallVector<Value*, 8> Args(II->op_begin(), II->op_end()-3);
|
SmallVector<Value*, 8> Args(II->op_begin(), II->op_end()-3);
|
||||||
Builder.SetInsertPoint(BI);
|
Builder.SetInsertPoint(BI);
|
||||||
CallInst *CI = Builder.CreateCall(II->getCalledValue(),
|
CallInst *CI = Builder.CreateCall(II->getCalledValue(),
|
||||||
Args.begin(), Args.end(),
|
Args, II->getName());
|
||||||
II->getName());
|
|
||||||
CI->setCallingConv(II->getCallingConv());
|
CI->setCallingConv(II->getCallingConv());
|
||||||
CI->setAttributes(II->getAttributes());
|
CI->setAttributes(II->getAttributes());
|
||||||
// If the invoke produced a value, the call does now instead.
|
// If the invoke produced a value, the call does now instead.
|
||||||
|
@ -198,7 +198,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
|
|||||||
Value *Operands[4] = { CI->getArgOperand(0), CI->getArgOperand(1),
|
Value *Operands[4] = { CI->getArgOperand(0), CI->getArgOperand(1),
|
||||||
CI->getArgOperand(2),
|
CI->getArgOperand(2),
|
||||||
llvm::ConstantInt::get(I32Ty, 1) };
|
llvm::ConstantInt::get(I32Ty, 1) };
|
||||||
CallInst *NewCI = CallInst::Create(NewFn, Operands, Operands+4,
|
CallInst *NewCI = CallInst::Create(NewFn, Operands,
|
||||||
CI->getName(), CI);
|
CI->getName(), CI);
|
||||||
NewCI->setTailCall(CI->isTailCall());
|
NewCI->setTailCall(CI->isTailCall());
|
||||||
NewCI->setCallingConv(CI->getCallingConv());
|
NewCI->setCallingConv(CI->getCallingConv());
|
||||||
|
@ -1680,7 +1680,7 @@ LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef B, LLVMValueRef Fn,
|
|||||||
LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
|
LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
|
||||||
const char *Name) {
|
const char *Name) {
|
||||||
return wrap(unwrap(B)->CreateInvoke(unwrap(Fn), unwrap(Then), unwrap(Catch),
|
return wrap(unwrap(B)->CreateInvoke(unwrap(Fn), unwrap(Then), unwrap(Catch),
|
||||||
unwrap(Args), unwrap(Args) + NumArgs,
|
ArrayRef<Value *>(unwrap(Args), NumArgs),
|
||||||
Name));
|
Name));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2063,8 +2063,9 @@ LLVMValueRef LLVMBuildPhi(LLVMBuilderRef B, LLVMTypeRef Ty, const char *Name) {
|
|||||||
LLVMValueRef LLVMBuildCall(LLVMBuilderRef B, LLVMValueRef Fn,
|
LLVMValueRef LLVMBuildCall(LLVMBuilderRef B, LLVMValueRef Fn,
|
||||||
LLVMValueRef *Args, unsigned NumArgs,
|
LLVMValueRef *Args, unsigned NumArgs,
|
||||||
const char *Name) {
|
const char *Name) {
|
||||||
return wrap(unwrap(B)->CreateCall(unwrap(Fn), unwrap(Args),
|
return wrap(unwrap(B)->CreateCall(unwrap(Fn),
|
||||||
unwrap(Args) + NumArgs, Name));
|
ArrayRef<Value *>(unwrap(Args), NumArgs),
|
||||||
|
Name));
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMValueRef LLVMBuildSelect(LLVMBuilderRef B, LLVMValueRef If,
|
LLVMValueRef LLVMBuildSelect(LLVMBuilderRef B, LLVMValueRef If,
|
||||||
|
@ -52,9 +52,9 @@ Value *IRBuilderBase::getCastedInt8PtrValue(Value *Ptr) {
|
|||||||
return BCI;
|
return BCI;
|
||||||
}
|
}
|
||||||
|
|
||||||
static CallInst *createCallHelper(Value *Callee, Value *const* Ops,
|
static CallInst *createCallHelper(Value *Callee, ArrayRef<Value *> Ops,
|
||||||
unsigned NumOps, IRBuilderBase *Builder) {
|
IRBuilderBase *Builder) {
|
||||||
CallInst *CI = CallInst::Create(Callee, Ops, Ops + NumOps, "");
|
CallInst *CI = CallInst::Create(Callee, Ops, "");
|
||||||
Builder->GetInsertBlock()->getInstList().insert(Builder->GetInsertPoint(),CI);
|
Builder->GetInsertBlock()->getInstList().insert(Builder->GetInsertPoint(),CI);
|
||||||
Builder->SetInstDebugLocation(CI);
|
Builder->SetInstDebugLocation(CI);
|
||||||
return CI;
|
return CI;
|
||||||
@ -69,7 +69,7 @@ CreateMemSet(Value *Ptr, Value *Val, Value *Size, unsigned Align,
|
|||||||
Module *M = BB->getParent()->getParent();
|
Module *M = BB->getParent()->getParent();
|
||||||
Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys);
|
Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys);
|
||||||
|
|
||||||
CallInst *CI = createCallHelper(TheFn, Ops, 5, this);
|
CallInst *CI = createCallHelper(TheFn, Ops, this);
|
||||||
|
|
||||||
// Set the TBAA info if present.
|
// Set the TBAA info if present.
|
||||||
if (TBAATag)
|
if (TBAATag)
|
||||||
@ -89,7 +89,7 @@ CreateMemCpy(Value *Dst, Value *Src, Value *Size, unsigned Align,
|
|||||||
Module *M = BB->getParent()->getParent();
|
Module *M = BB->getParent()->getParent();
|
||||||
Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memcpy, Tys);
|
Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memcpy, Tys);
|
||||||
|
|
||||||
CallInst *CI = createCallHelper(TheFn, Ops, 5, this);
|
CallInst *CI = createCallHelper(TheFn, Ops, this);
|
||||||
|
|
||||||
// Set the TBAA info if present.
|
// Set the TBAA info if present.
|
||||||
if (TBAATag)
|
if (TBAATag)
|
||||||
@ -109,7 +109,7 @@ CreateMemMove(Value *Dst, Value *Src, Value *Size, unsigned Align,
|
|||||||
Module *M = BB->getParent()->getParent();
|
Module *M = BB->getParent()->getParent();
|
||||||
Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memmove, Tys);
|
Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memmove, Tys);
|
||||||
|
|
||||||
CallInst *CI = createCallHelper(TheFn, Ops, 5, this);
|
CallInst *CI = createCallHelper(TheFn, Ops, this);
|
||||||
|
|
||||||
// Set the TBAA info if present.
|
// Set the TBAA info if present.
|
||||||
if (TBAATag)
|
if (TBAATag)
|
||||||
@ -130,7 +130,7 @@ CallInst *IRBuilderBase::CreateLifetimeStart(Value *Ptr, ConstantInt *Size) {
|
|||||||
Value *Ops[] = { Size, Ptr };
|
Value *Ops[] = { Size, Ptr };
|
||||||
Module *M = BB->getParent()->getParent();
|
Module *M = BB->getParent()->getParent();
|
||||||
Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::lifetime_start);
|
Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::lifetime_start);
|
||||||
return createCallHelper(TheFn, Ops, 2, this);
|
return createCallHelper(TheFn, Ops, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
CallInst *IRBuilderBase::CreateLifetimeEnd(Value *Ptr, ConstantInt *Size) {
|
CallInst *IRBuilderBase::CreateLifetimeEnd(Value *Ptr, ConstantInt *Size) {
|
||||||
@ -145,5 +145,5 @@ CallInst *IRBuilderBase::CreateLifetimeEnd(Value *Ptr, ConstantInt *Size) {
|
|||||||
Value *Ops[] = { Size, Ptr };
|
Value *Ops[] = { Size, Ptr };
|
||||||
Module *M = BB->getParent()->getParent();
|
Module *M = BB->getParent()->getParent();
|
||||||
Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::lifetime_end);
|
Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::lifetime_end);
|
||||||
return createCallHelper(TheFn, Ops, 2, this);
|
return createCallHelper(TheFn, Ops, this);
|
||||||
}
|
}
|
||||||
|
@ -174,95 +174,42 @@ Value *PHINode::hasConstantValue() const {
|
|||||||
CallInst::~CallInst() {
|
CallInst::~CallInst() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CallInst::init(Value *Func, Value* const *Params, unsigned NumParams) {
|
void CallInst::init(Value *Func, ArrayRef<Value *> Args, const Twine &NameStr) {
|
||||||
assert(NumOperands == NumParams+1 && "NumOperands not set up?");
|
assert(NumOperands == Args.size() + 1 && "NumOperands not set up?");
|
||||||
Op<-1>() = Func;
|
Op<-1>() = Func;
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
const FunctionType *FTy =
|
const FunctionType *FTy =
|
||||||
cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType());
|
cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType());
|
||||||
(void)FTy; // silence warning.
|
|
||||||
|
|
||||||
assert((NumParams == FTy->getNumParams() ||
|
assert((Args.size() == FTy->getNumParams() ||
|
||||||
(FTy->isVarArg() && NumParams > FTy->getNumParams())) &&
|
(FTy->isVarArg() && Args.size() > FTy->getNumParams())) &&
|
||||||
"Calling a function with bad signature!");
|
"Calling a function with bad signature!");
|
||||||
for (unsigned i = 0; i != NumParams; ++i) {
|
|
||||||
|
for (unsigned i = 0; i != Args.size(); ++i)
|
||||||
assert((i >= FTy->getNumParams() ||
|
assert((i >= FTy->getNumParams() ||
|
||||||
FTy->getParamType(i) == Params[i]->getType()) &&
|
FTy->getParamType(i) == Args[i]->getType()) &&
|
||||||
"Calling a function with a bad signature!");
|
"Calling a function with a bad signature!");
|
||||||
OperandList[i] = Params[i];
|
#endif
|
||||||
}
|
|
||||||
|
std::copy(Args.begin(), Args.end(), op_begin());
|
||||||
|
setName(NameStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CallInst::init(Value *Func, Value *Actual1, Value *Actual2) {
|
void CallInst::init(Value *Func, const Twine &NameStr) {
|
||||||
assert(NumOperands == 3 && "NumOperands not set up?");
|
|
||||||
Op<-1>() = Func;
|
|
||||||
Op<0>() = Actual1;
|
|
||||||
Op<1>() = Actual2;
|
|
||||||
|
|
||||||
const FunctionType *FTy =
|
|
||||||
cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType());
|
|
||||||
(void)FTy; // silence warning.
|
|
||||||
|
|
||||||
assert((FTy->getNumParams() == 2 ||
|
|
||||||
(FTy->isVarArg() && FTy->getNumParams() < 2)) &&
|
|
||||||
"Calling a function with bad signature");
|
|
||||||
assert((0 >= FTy->getNumParams() ||
|
|
||||||
FTy->getParamType(0) == Actual1->getType()) &&
|
|
||||||
"Calling a function with a bad signature!");
|
|
||||||
assert((1 >= FTy->getNumParams() ||
|
|
||||||
FTy->getParamType(1) == Actual2->getType()) &&
|
|
||||||
"Calling a function with a bad signature!");
|
|
||||||
}
|
|
||||||
|
|
||||||
void CallInst::init(Value *Func, Value *Actual) {
|
|
||||||
assert(NumOperands == 2 && "NumOperands not set up?");
|
|
||||||
Op<-1>() = Func;
|
|
||||||
Op<0>() = Actual;
|
|
||||||
|
|
||||||
const FunctionType *FTy =
|
|
||||||
cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType());
|
|
||||||
(void)FTy; // silence warning.
|
|
||||||
|
|
||||||
assert((FTy->getNumParams() == 1 ||
|
|
||||||
(FTy->isVarArg() && FTy->getNumParams() == 0)) &&
|
|
||||||
"Calling a function with bad signature");
|
|
||||||
assert((0 == FTy->getNumParams() ||
|
|
||||||
FTy->getParamType(0) == Actual->getType()) &&
|
|
||||||
"Calling a function with a bad signature!");
|
|
||||||
}
|
|
||||||
|
|
||||||
void CallInst::init(Value *Func) {
|
|
||||||
assert(NumOperands == 1 && "NumOperands not set up?");
|
assert(NumOperands == 1 && "NumOperands not set up?");
|
||||||
Op<-1>() = Func;
|
Op<-1>() = Func;
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
const FunctionType *FTy =
|
const FunctionType *FTy =
|
||||||
cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType());
|
cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType());
|
||||||
(void)FTy; // silence warning.
|
|
||||||
|
|
||||||
assert(FTy->getNumParams() == 0 && "Calling a function with bad signature");
|
assert(FTy->getNumParams() == 0 && "Calling a function with bad signature");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
setName(NameStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
CallInst::CallInst(Value *Func, Value* Actual, const Twine &Name,
|
|
||||||
Instruction *InsertBefore)
|
|
||||||
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
|
|
||||||
->getElementType())->getReturnType(),
|
|
||||||
Instruction::Call,
|
|
||||||
OperandTraits<CallInst>::op_end(this) - 2,
|
|
||||||
2, InsertBefore) {
|
|
||||||
init(Func, Actual);
|
|
||||||
setName(Name);
|
|
||||||
}
|
|
||||||
|
|
||||||
CallInst::CallInst(Value *Func, Value* Actual, const Twine &Name,
|
|
||||||
BasicBlock *InsertAtEnd)
|
|
||||||
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
|
|
||||||
->getElementType())->getReturnType(),
|
|
||||||
Instruction::Call,
|
|
||||||
OperandTraits<CallInst>::op_end(this) - 2,
|
|
||||||
2, InsertAtEnd) {
|
|
||||||
init(Func, Actual);
|
|
||||||
setName(Name);
|
|
||||||
}
|
|
||||||
CallInst::CallInst(Value *Func, const Twine &Name,
|
CallInst::CallInst(Value *Func, const Twine &Name,
|
||||||
Instruction *InsertBefore)
|
Instruction *InsertBefore)
|
||||||
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
|
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
|
||||||
@ -270,8 +217,7 @@ CallInst::CallInst(Value *Func, const Twine &Name,
|
|||||||
Instruction::Call,
|
Instruction::Call,
|
||||||
OperandTraits<CallInst>::op_end(this) - 1,
|
OperandTraits<CallInst>::op_end(this) - 1,
|
||||||
1, InsertBefore) {
|
1, InsertBefore) {
|
||||||
init(Func);
|
init(Func, Name);
|
||||||
setName(Name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CallInst::CallInst(Value *Func, const Twine &Name,
|
CallInst::CallInst(Value *Func, const Twine &Name,
|
||||||
@ -281,8 +227,7 @@ CallInst::CallInst(Value *Func, const Twine &Name,
|
|||||||
Instruction::Call,
|
Instruction::Call,
|
||||||
OperandTraits<CallInst>::op_end(this) - 1,
|
OperandTraits<CallInst>::op_end(this) - 1,
|
||||||
1, InsertAtEnd) {
|
1, InsertAtEnd) {
|
||||||
init(Func);
|
init(Func, Name);
|
||||||
setName(Name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CallInst::CallInst(const CallInst &CI)
|
CallInst::CallInst(const CallInst &CI)
|
||||||
@ -293,10 +238,7 @@ CallInst::CallInst(const CallInst &CI)
|
|||||||
setTailCall(CI.isTailCall());
|
setTailCall(CI.isTailCall());
|
||||||
setCallingConv(CI.getCallingConv());
|
setCallingConv(CI.getCallingConv());
|
||||||
|
|
||||||
Use *OL = OperandList;
|
std::copy(CI.op_begin(), CI.op_end(), op_begin());
|
||||||
Use *InOL = CI.OperandList;
|
|
||||||
for (unsigned i = 0, e = CI.getNumOperands(); i != e; ++i)
|
|
||||||
OL[i] = InOL[i];
|
|
||||||
SubclassOptionalData = CI.SubclassOptionalData;
|
SubclassOptionalData = CI.SubclassOptionalData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -487,27 +429,28 @@ Instruction* CallInst::CreateFree(Value* Source, BasicBlock *InsertAtEnd) {
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
void InvokeInst::init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
|
void InvokeInst::init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
|
||||||
Value* const *Args, unsigned NumArgs) {
|
ArrayRef<Value *> Args, const Twine &NameStr) {
|
||||||
assert(NumOperands == 3+NumArgs && "NumOperands not set up?");
|
assert(NumOperands == 3 + Args.size() && "NumOperands not set up?");
|
||||||
Op<-3>() = Fn;
|
Op<-3>() = Fn;
|
||||||
Op<-2>() = IfNormal;
|
Op<-2>() = IfNormal;
|
||||||
Op<-1>() = IfException;
|
Op<-1>() = IfException;
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
const FunctionType *FTy =
|
const FunctionType *FTy =
|
||||||
cast<FunctionType>(cast<PointerType>(Fn->getType())->getElementType());
|
cast<FunctionType>(cast<PointerType>(Fn->getType())->getElementType());
|
||||||
(void)FTy; // silence warning.
|
|
||||||
|
|
||||||
assert(((NumArgs == FTy->getNumParams()) ||
|
assert(((Args.size() == FTy->getNumParams()) ||
|
||||||
(FTy->isVarArg() && NumArgs > FTy->getNumParams())) &&
|
(FTy->isVarArg() && Args.size() > FTy->getNumParams())) &&
|
||||||
"Invoking a function with bad signature");
|
"Invoking a function with bad signature");
|
||||||
|
|
||||||
Use *OL = OperandList;
|
for (unsigned i = 0, e = Args.size(); i != e; i++)
|
||||||
for (unsigned i = 0, e = NumArgs; i != e; i++) {
|
|
||||||
assert((i >= FTy->getNumParams() ||
|
assert((i >= FTy->getNumParams() ||
|
||||||
FTy->getParamType(i) == Args[i]->getType()) &&
|
FTy->getParamType(i) == Args[i]->getType()) &&
|
||||||
"Invoking a function with a bad signature!");
|
"Invoking a function with a bad signature!");
|
||||||
|
#endif
|
||||||
OL[i] = Args[i];
|
|
||||||
}
|
std::copy(Args.begin(), Args.end(), op_begin());
|
||||||
|
setName(NameStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
InvokeInst::InvokeInst(const InvokeInst &II)
|
InvokeInst::InvokeInst(const InvokeInst &II)
|
||||||
@ -517,9 +460,7 @@ InvokeInst::InvokeInst(const InvokeInst &II)
|
|||||||
II.getNumOperands()) {
|
II.getNumOperands()) {
|
||||||
setAttributes(II.getAttributes());
|
setAttributes(II.getAttributes());
|
||||||
setCallingConv(II.getCallingConv());
|
setCallingConv(II.getCallingConv());
|
||||||
Use *OL = OperandList, *InOL = II.OperandList;
|
std::copy(II.op_begin(), II.op_end(), op_begin());
|
||||||
for (unsigned i = 0, e = II.getNumOperands(); i != e; ++i)
|
|
||||||
OL[i] = InOL[i];
|
|
||||||
SubclassOptionalData = II.SubclassOptionalData;
|
SubclassOptionalData = II.SubclassOptionalData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -794,8 +794,7 @@ static void CleanupAndPrepareModules(BugDriver &BD, Module *&Test,
|
|||||||
|
|
||||||
// Call the old main function and return its result
|
// Call the old main function and return its result
|
||||||
BasicBlock *BB = BasicBlock::Create(Safe->getContext(), "entry", newMain);
|
BasicBlock *BB = BasicBlock::Create(Safe->getContext(), "entry", newMain);
|
||||||
CallInst *call = CallInst::Create(oldMainProto, args.begin(), args.end(),
|
CallInst *call = CallInst::Create(oldMainProto, args, "", BB);
|
||||||
"", BB);
|
|
||||||
|
|
||||||
// If the type of old function wasn't void, return value of call
|
// If the type of old function wasn't void, return value of call
|
||||||
ReturnInst::Create(Safe->getContext(), call, BB);
|
ReturnInst::Create(Safe->getContext(), call, BB);
|
||||||
@ -873,8 +872,7 @@ static void CleanupAndPrepareModules(BugDriver &BD, Module *&Test,
|
|||||||
//
|
//
|
||||||
// call resolver(GetElementPtr...)
|
// call resolver(GetElementPtr...)
|
||||||
CallInst *Resolver =
|
CallInst *Resolver =
|
||||||
CallInst::Create(resolverFunc, ResolverArgs.begin(),
|
CallInst::Create(resolverFunc, ResolverArgs, "resolver", LookupBB);
|
||||||
ResolverArgs.end(), "resolver", LookupBB);
|
|
||||||
|
|
||||||
// Cast the result from the resolver to correctly-typed function.
|
// Cast the result from the resolver to correctly-typed function.
|
||||||
CastInst *CastedResolver =
|
CastInst *CastedResolver =
|
||||||
@ -899,10 +897,10 @@ static void CleanupAndPrepareModules(BugDriver &BD, Module *&Test,
|
|||||||
|
|
||||||
// Pass on the arguments to the real function, return its result
|
// Pass on the arguments to the real function, return its result
|
||||||
if (F->getReturnType()->isVoidTy()) {
|
if (F->getReturnType()->isVoidTy()) {
|
||||||
CallInst::Create(FuncPtr, Args.begin(), Args.end(), "", DoCallBB);
|
CallInst::Create(FuncPtr, Args, "", DoCallBB);
|
||||||
ReturnInst::Create(F->getContext(), DoCallBB);
|
ReturnInst::Create(F->getContext(), DoCallBB);
|
||||||
} else {
|
} else {
|
||||||
CallInst *Call = CallInst::Create(FuncPtr, Args.begin(), Args.end(),
|
CallInst *Call = CallInst::Create(FuncPtr, Args,
|
||||||
"retval", DoCallBB);
|
"retval", DoCallBB);
|
||||||
ReturnInst::Create(F->getContext(),Call, DoCallBB);
|
ReturnInst::Create(F->getContext(),Call, DoCallBB);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user