本文整理汇总了C++中InvokeInst::takeName方法的典型用法代码示例。如果您正苦于以下问题:C++ InvokeInst::takeName方法的具体用法?C++ InvokeInst::takeName怎么用?C++ InvokeInst::takeName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InvokeInst
的用法示例。
在下文中一共展示了InvokeInst::takeName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConvertCall
// Convert the given call to use normalized argument/return types.
template <class T> static bool ConvertCall(T *Call, Pass *P) {
// Don't try to change calls to intrinsics.
if (isa<IntrinsicInst>(Call))
return false;
FunctionType *FTy = cast<FunctionType>(
Call->getCalledValue()->getType()->getPointerElementType());
FunctionType *NFTy = NormalizeFunctionType(FTy);
if (NFTy == FTy)
return false; // No change needed.
// Convert arguments.
SmallVector<Value *, 8> Args;
for (unsigned I = 0; I < Call->getNumArgOperands(); ++I) {
Value *Arg = Call->getArgOperand(I);
if (NFTy->getParamType(I) != FTy->getParamType(I)) {
Instruction::CastOps CastType =
Call->getAttributes().hasAttribute(I + 1, Attribute::SExt) ?
Instruction::SExt : Instruction::ZExt;
Arg = CopyDebug(CastInst::Create(CastType, Arg, NFTy->getParamType(I),
"arg_ext", Call), Call);
}
Args.push_back(Arg);
}
Value *CastFunc =
CopyDebug(new BitCastInst(Call->getCalledValue(), NFTy->getPointerTo(),
Call->getName() + ".arg_cast", Call), Call);
Value *Result = NULL;
if (CallInst *OldCall = dyn_cast<CallInst>(Call)) {
CallInst *NewCall = CopyDebug(CallInst::Create(CastFunc, Args, "", OldCall),
OldCall);
NewCall->takeName(OldCall);
NewCall->setAttributes(OldCall->getAttributes());
NewCall->setCallingConv(OldCall->getCallingConv());
NewCall->setTailCall(OldCall->isTailCall());
Result = NewCall;
if (FTy->getReturnType() != NFTy->getReturnType()) {
Result = CopyDebug(new TruncInst(NewCall, FTy->getReturnType(),
NewCall->getName() + ".ret_trunc", Call),
Call);
}
} else if (InvokeInst *OldInvoke = dyn_cast<InvokeInst>(Call)) {
BasicBlock *Parent = OldInvoke->getParent();
BasicBlock *NormalDest = OldInvoke->getNormalDest();
BasicBlock *UnwindDest = OldInvoke->getUnwindDest();
if (FTy->getReturnType() != NFTy->getReturnType()) {
if (BasicBlock *SplitDest = SplitCriticalEdge(Parent, NormalDest)) {
NormalDest = SplitDest;
}
}
InvokeInst *New = CopyDebug(InvokeInst::Create(CastFunc, NormalDest,
UnwindDest, Args,
"", OldInvoke),
OldInvoke);
New->takeName(OldInvoke);
if (FTy->getReturnType() != NFTy->getReturnType()) {
Result = CopyDebug(new TruncInst(New, FTy->getReturnType(),
New->getName() + ".ret_trunc",
NormalDest->getTerminator()),
OldInvoke);
} else {
Result = New;
}
New->setAttributes(OldInvoke->getAttributes());
New->setCallingConv(OldInvoke->getCallingConv());
}
Call->replaceAllUsesWith(Result);
Call->eraseFromParent();
return true;
}