本文整理汇总了C++中GEPOperator::op_end方法的典型用法代码示例。如果您正苦于以下问题:C++ GEPOperator::op_end方法的具体用法?C++ GEPOperator::op_end怎么用?C++ GEPOperator::op_end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GEPOperator
的用法示例。
在下文中一共展示了GEPOperator::op_end方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runOnModule
//.........这里部分代码省略.........
// Construct the new Type
// Appends the struct Type at the beginning
std::vector<Type*>TP;
TP.push_back(GEP->getPointerOperand()->getType());
for(unsigned c = 1; c < CI->getNumOperands();c++) {
TP.push_back(CI->getOperand(c)->getType());
}
//return type is same as that of original instruction
FunctionType *NewFTy = FunctionType::get(CI->getType(), TP, false);
Function *NewF;
numSimplified++;
if(numSimplified > 800)
return true;
NewF = Function::Create(NewFTy,
GlobalValue::InternalLinkage,
F->getName().str() + ".TEST",
&M);
Function::arg_iterator NI = NewF->arg_begin();
NI->setName("GEParg");
++NI;
ValueToValueMapTy ValueMap;
for (Function::arg_iterator II = F->arg_begin(); NI != NewF->arg_end(); ++II, ++NI) {
ValueMap[II] = NI;
NI->setName(II->getName());
NI->addAttr(F->getAttributes().getParamAttributes(II->getArgNo() + 1));
}
NewF->setAttributes(NewF->getAttributes().addAttr(
0, F->getAttributes().getRetAttributes()));
// Perform the cloning.
SmallVector<ReturnInst*,100> Returns;
CloneFunctionInto(NewF, F, ValueMap, false, Returns);
std::vector<Value*> fargs;
for(Function::arg_iterator ai = NewF->arg_begin(),
ae= NewF->arg_end(); ai != ae; ++ai) {
fargs.push_back(ai);
}
NewF->setAttributes(NewF->getAttributes().addAttr(
~0, F->getAttributes().getFnAttributes()));
//Get the point to insert the GEP instr.
SmallVector<Value*, 8> Ops(CI->op_begin()+1, CI->op_end());
Instruction *InsertPoint;
for (BasicBlock::iterator insrt = NewF->front().begin();
isa<AllocaInst>(InsertPoint = insrt); ++insrt) {;}
NI = NewF->arg_begin();
SmallVector<Value*, 8> Indices;
Indices.append(GEP->op_begin()+1, GEP->op_end());
GetElementPtrInst *GEP_new = GetElementPtrInst::Create(cast<Value>(NI),
Indices,
"", InsertPoint);
fargs.at(argNum)->replaceAllUsesWith(GEP_new);
unsigned j = argNum + 1;
for(; j < CI->getNumOperands();j++) {
if(CI->getOperand(j) == GEP)
fargs.at(j)->replaceAllUsesWith(GEP_new);
}
SmallVector<AttributeWithIndex, 8> AttributesVec;
// Get the initial attributes of the call
AttrListPtr CallPAL = CI->getAttributes();
Attributes RAttrs = CallPAL.getRetAttributes();
Attributes FnAttrs = CallPAL.getFnAttributes();
if (RAttrs)
AttributesVec.push_back(AttributeWithIndex::get(0, RAttrs));
SmallVector<Value*, 8> Args;
Args.push_back(GEP->getPointerOperand());
for(unsigned j =1;j<CI->getNumOperands();j++) {
Args.push_back(CI->getOperand(j));
// position in the AttributesVec
if (Attributes Attrs = CallPAL.getParamAttributes(j))
AttributesVec.push_back(AttributeWithIndex::get(Args.size(), Attrs));
}
// Create the new attributes vec.
if (FnAttrs != Attribute::None)
AttributesVec.push_back(AttributeWithIndex::get(~0, FnAttrs));
AttrListPtr NewCallPAL = AttrListPtr::get(AttributesVec.begin(),
AttributesVec.end());
CallInst *CallI = CallInst::Create(NewF,Args,"", CI);
CallI->setCallingConv(CI->getCallingConv());
CallI->setAttributes(NewCallPAL);
CI->replaceAllUsesWith(CallI);
CI->eraseFromParent();
changed = true;
}
}
}
} while(changed);
return true;
}