本文整理汇总了C++中function::iterator::end方法的典型用法代码示例。如果您正苦于以下问题:C++ iterator::end方法的具体用法?C++ iterator::end怎么用?C++ iterator::end使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类function::iterator
的用法示例。
在下文中一共展示了iterator::end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConvertFunction
// Convert the given function to use normalized argument/return types.
static bool ConvertFunction(Function *Func) {
FunctionType *FTy = Func->getFunctionType();
FunctionType *NFTy = NormalizeFunctionType(FTy);
if (NFTy == FTy)
return false; // No change needed.
Function *NewFunc = RecreateFunction(Func, NFTy);
// Move the arguments across to the new function.
for (Function::arg_iterator Arg = Func->arg_begin(), E = Func->arg_end(),
NewArg = NewFunc->arg_begin();
Arg != E; ++Arg, ++NewArg) {
NewArg->takeName(Arg);
if (Arg->getType() == NewArg->getType()) {
Arg->replaceAllUsesWith(NewArg);
} else {
Instruction *Trunc = new TruncInst(
NewArg, Arg->getType(), NewArg->getName() + ".arg_trunc",
NewFunc->getEntryBlock().getFirstInsertionPt());
Arg->replaceAllUsesWith(Trunc);
}
}
if (FTy->getReturnType() != NFTy->getReturnType()) {
// Fix up return instructions.
Instruction::CastOps CastType =
Func->getAttributes().hasAttribute(0, Attribute::SExt) ?
Instruction::SExt : Instruction::ZExt;
for (Function::iterator BB = NewFunc->begin(), E = NewFunc->end();
BB != E;
++BB) {
for (BasicBlock::iterator Iter = BB->begin(), E = BB->end();
Iter != E; ) {
Instruction *Inst = Iter++;
if (ReturnInst *Ret = dyn_cast<ReturnInst>(Inst)) {
Value *Ext = CopyDebug(
CastInst::Create(CastType, Ret->getReturnValue(),
NFTy->getReturnType(),
Ret->getReturnValue()->getName() + ".ret_ext",
Ret),
Ret);
CopyDebug(ReturnInst::Create(Ret->getContext(), Ext, Ret), Ret);
Ret->eraseFromParent();
}
}
}
}
Func->eraseFromParent();
return true;
}
示例2: runOnFunction
bool SSIEverything::runOnFunction(Function &F) {
SmallVector<Instruction *, 16> Insts;
SSI &ssi = getAnalysis<SSI>();
if (F.isDeclaration() || F.isIntrinsic()) return false;
for (Function::iterator B = F.begin(), BE = F.end(); B != BE; ++B)
for (BasicBlock::iterator I = B->begin(), E = B->end(); I != E; ++I)
if (!I->getType()->isVoidTy())
Insts.push_back(I);
ssi.createSSI(Insts);
return true;
}
示例3: CollectLiveInput
void StructFieldReach::CollectLiveInput(Function * pFunction, vector< pair<MemFootPrint *, int> > & vecLiveInput )
{
ReturnInst * pRet = NULL;
for(Function::iterator BB = pFunction->begin(); BB != pFunction->end(); BB++)
{
for(BasicBlock::iterator II = BB->begin(); II != BB->end(); II ++)
{
if(ReturnInst * pR = dyn_cast<ReturnInst>(II))
{
pRet = pR;
}
}
}
vector<Argument *> vecArgument;
for(Function::arg_iterator argBe = pFunction->arg_begin(); argBe != pFunction->arg_end(); argBe ++ )
{
vecArgument.push_back(argBe);
}
set<MemFootPrint *>::iterator itSetBegin = this->InstBeforeSetMapping[pRet].begin();
set<MemFootPrint *>::iterator itSetEnd = this->InstBeforeSetMapping[pRet].end();
for(; itSetBegin != itSetEnd; itSetBegin ++ )
{
vector<Argument *>::iterator itVecArgBegin = vecArgument.begin();
vector<Argument *>::iterator itVecArgEnd = vecArgument.end();
int iIndex = 0;
for(; itVecArgBegin != itVecArgEnd; itVecArgBegin++)
{
if(*itVecArgBegin == (*itSetBegin)->pBaseObject)
{
pair<MemFootPrint *, int> pairTmp;
pairTmp.first = *itSetBegin;
pairTmp.second = iIndex;
vecLiveInput.push_back(pairTmp);
}
iIndex ++;
}
}
}
示例4: TestInsts
bool ReduceCrashingInstructions::TestInsts(std::vector<const Instruction*>
&Insts) {
// Clone the program to try hacking it apart...
ValueToValueMapTy VMap;
Module *M = CloneModule(BD.getProgram(), VMap);
// Convert list to set for fast lookup...
SmallPtrSet<Instruction*, 64> Instructions;
for (unsigned i = 0, e = Insts.size(); i != e; ++i) {
assert(!isa<TerminatorInst>(Insts[i]));
Instructions.insert(cast<Instruction>(VMap[Insts[i]]));
}
outs() << "Checking for crash with only " << Instructions.size();
if (Instructions.size() == 1)
outs() << " instruction: ";
else
outs() << " instructions: ";
for (Module::iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI)
for (Function::iterator FI = MI->begin(), FE = MI->end(); FI != FE; ++FI)
for (BasicBlock::iterator I = FI->begin(), E = FI->end(); I != E;) {
Instruction *Inst = &*I++;
if (!Instructions.count(Inst) && !isa<TerminatorInst>(Inst) &&
!Inst->isEHPad()) {
if (!Inst->getType()->isVoidTy())
Inst->replaceAllUsesWith(UndefValue::get(Inst->getType()));
Inst->eraseFromParent();
}
}
// Verify that this is still valid.
legacy::PassManager Passes;
Passes.add(createVerifierPass());
Passes.run(*M);
// Try running on the hacked up program...
if (TestFn(BD, M)) {
BD.setNewProgram(M); // It crashed, keep the trimmed version...
// Make sure to use instruction pointers that point into the now-current
// module, and that they don't include any deleted blocks.
Insts.clear();
for (Instruction *Inst : Instructions)
Insts.push_back(Inst);
return true;
}
delete M; // It didn't crash, try something else.
return false;
}
示例5: insertLoadInstCheck
void LLSTDebuggingPass::insertLoadInstCheck(Function& F)
{
Value* BrokenPointerMessage = m_builder->CreateGlobalStringPtr("\npointer is broken\n");
InstructionVector Loads;
for (Function::iterator BB = F.begin(); BB != F.end(); ++BB)
{
for(BasicBlock::iterator II = BB->begin(); II != BB->end(); ++II)
{
if (LoadInst* Load = dyn_cast<LoadInst>(II)) {
Loads.push_back(Load);
}
}
}
for(std::size_t i = 0; i < Loads.size(); i++)
{
LoadInst* Load = dyn_cast<LoadInst>(Loads[i]);
if (belongsToSmalltalkType( Load->getType() )) {
//split BB right after load inst. The new BB contains code that will be executed if pointer is OK
BasicBlock* PointerIsOkBB = Load->getParent()->splitBasicBlock(++( static_cast<BasicBlock::iterator>(Load) ));
BasicBlock* PointerIsBrokenBB = BasicBlock::Create(m_module->getContext(), "", &F, PointerIsOkBB);
BasicBlock* PointerIsNotSmallIntBB = BasicBlock::Create(m_module->getContext(), "", &F, PointerIsBrokenBB);
Instruction* branchToPointerIsOkBB = ++( static_cast<BasicBlock::iterator>(Load) );
//branchToPointerIsOkBB is created by splitBasicBlock() just after load inst
//We force builder to insert instructions before branchToPointerIsOkBB
m_builder->SetInsertPoint(branchToPointerIsOkBB);
//If pointer to class is null, jump to PointerIsBroken, otherwise to PointerIsOkBB
Value* objectPtr = m_builder->CreateBitCast( Load, m_baseTypes.object->getPointerTo());
Value* isSmallInt = m_builder->CreateCall(isSmallInteger, objectPtr);
m_builder->CreateCondBr(isSmallInt, PointerIsOkBB, PointerIsNotSmallIntBB);
m_builder->SetInsertPoint(PointerIsNotSmallIntBB);
Value* klassPtr = m_builder->CreateCall(getObjectClass, objectPtr);
Value* pointerIsNull = m_builder->CreateICmpEQ(klassPtr, ConstantPointerNull::get(m_baseTypes.klass->getPointerTo()) );
m_builder->CreateCondBr(pointerIsNull, PointerIsBrokenBB, PointerIsOkBB);
branchToPointerIsOkBB->eraseFromParent(); //We don't need it anymore
m_builder->SetInsertPoint(PointerIsBrokenBB);
m_builder->CreateCall(_printf, BrokenPointerMessage);
m_builder->CreateBr(PointerIsOkBB);
}
}
}
示例6: runOnFunction
virtual bool runOnFunction(Function &F) {
bool isChanged = false;
for (Function::iterator BB = F.begin(), EE = F.end(); BB != EE; ++BB) {
for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E;) {
Instruction *instr = I;
++I;
if (instr->getOpcode() == Instruction::UDiv) {
isChanged |= lowerUDiv(instr);
} else if (instr->getOpcode() == Instruction::SDiv) {
isChanged |= lowerSDiv(instr);
}
}
}
return isChanged;
}
示例7: runOnModule
bool AdvancedInstCounter::runOnModule(Module &M) {
unsigned NumIndirectCalls = 0;
for (Module::iterator F = M.begin(); F != M.end(); ++F) {
for (Function::iterator B = F->begin(); B != F->end(); ++B) {
for (BasicBlock::iterator I = B->begin(); I != B->end(); ++I) {
CallSite CS(I);
if (CS && CS.getCalledFunction() == NULL) {
++NumIndirectCalls;
}
}
}
}
errs() << "# of indirect calls = " << NumIndirectCalls << "\n";
return false;
}
示例8: addDefinedFunctionSymbol
void LTOModule::addDefinedFunctionSymbol(Function* f, Mangler &mangler)
{
// add to list of defined symbols
addDefinedSymbol(f, mangler, true);
// add external symbols referenced by this function.
for (Function::iterator b = f->begin(); b != f->end(); ++b) {
for (BasicBlock::iterator i = b->begin(); i != b->end(); ++i) {
for (unsigned count = 0, total = i->getNumOperands();
count != total; ++count) {
findExternalRefs(i->getOperand(count), mangler);
}
}
}
}
示例9: BuildMemFootPrintMapping
void StructFieldReach::BuildMemFootPrintMapping(Function * pFunction)
{
for(Function::iterator BB = pFunction->begin(); BB != pFunction->end(); BB ++ )
{
for(BasicBlock::iterator II = BB->begin(); II != BB->end(); II ++ )
{
if(isa<LoadInst>(II) || isa<StoreInst>(II) || isa<MemIntrinsic>(II))
{
MemFootPrint foot;
CalMemFootPrint(II, &foot, this->pDL);
this->InstMemFootPrintMapping[II] = foot;
}
}
}
}
示例10: GlobalIsNeeded
/// GlobalIsNeeded - the specific global value as needed, and
/// recursively mark anything that it uses as also needed.
void GlobalDCE::GlobalIsNeeded(GlobalValue *G) {
// If the global is already in the set, no need to reprocess it.
if (!AliveGlobals.insert(G).second)
return;
Module *M = G->getParent();
if (Comdat *C = G->getComdat()) {
for (Function &F : *M)
if (F.getComdat() == C)
GlobalIsNeeded(&F);
for (GlobalVariable &GV : M->globals())
if (GV.getComdat() == C)
GlobalIsNeeded(&GV);
for (GlobalAlias &GA : M->aliases())
if (GA.getComdat() == C)
GlobalIsNeeded(&GA);
}
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(G)) {
// If this is a global variable, we must make sure to add any global values
// referenced by the initializer to the alive set.
if (GV->hasInitializer())
MarkUsedGlobalsAsNeeded(GV->getInitializer());
} else if (GlobalAlias *GA = dyn_cast<GlobalAlias>(G)) {
// The target of a global alias is needed.
MarkUsedGlobalsAsNeeded(GA->getAliasee());
} else {
// Otherwise this must be a function object. We have to scan the body of
// the function looking for constants and global values which are used as
// operands. Any operands of these types must be processed to ensure that
// any globals used will be marked as needed.
Function *F = cast<Function>(G);
if (F->hasPrefixData())
MarkUsedGlobalsAsNeeded(F->getPrefixData());
if (F->hasPrologueData())
MarkUsedGlobalsAsNeeded(F->getPrologueData());
for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB)
for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I)
for (User::op_iterator U = I->op_begin(), E = I->op_end(); U != E; ++U)
if (GlobalValue *GV = dyn_cast<GlobalValue>(*U))
GlobalIsNeeded(GV);
else if (Constant *C = dyn_cast<Constant>(*U))
MarkUsedGlobalsAsNeeded(C);
}
}
示例11: runOnFunction
bool SeparateConstOffsetFromGEP::runOnFunction(Function &F) {
if (DisableSeparateConstOffsetFromGEP)
return false;
bool Changed = false;
for (Function::iterator B = F.begin(), BE = F.end(); B != BE; ++B) {
for (BasicBlock::iterator I = B->begin(), IE = B->end(); I != IE; ) {
if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(I++)) {
Changed |= splitGEP(GEP);
}
// No need to split GEP ConstantExprs because all its indices are constant
// already.
}
}
return Changed;
}
示例12: runOnModule
bool DynInstMarker::runOnModule(Module& m) {
bool retVal = initInstrumentation(m);
errs() << retVal << "\n";
for (Module::iterator fi = m.begin(), fe = m.end(); fi != fe; ++fi) {
errs().write_escaped(fi->getName()) << "\n";
for (Function::iterator bi = fi->begin(), be = fi->end(); bi != be; ++bi) {
for (BasicBlock::iterator ii = bi->begin(), ie = bi->end(); ii != ie; ++ii) {
if (isa<LoadInst>(*ii) &&
!fi->getName().equals(StringRef("_Z13resMarkerFuncv"))) { // TODO: optimize this
insertInstrumentation(ii, bi, &m);
}
}
}
}
return retVal;
}
示例13: preprocess
//
// Method: preprocess()
//
// Description:
// %p = bitcast %p1 to T1
// gep(%p) ...
// ->
// gep (bitcast %p1 to T1), ...
//
// Inputs:
// M - A reference to the LLVM module to process
//
// Outputs:
// M - The transformed LLVM module.
//
static void preprocess(Module& M) {
for (Module::iterator F = M.begin(); F != M.end(); ++F){
for (Function::iterator B = F->begin(), FE = F->end(); B != FE; ++B) {
for (BasicBlock::iterator I = B->begin(), BE = B->end(); I != BE; I++) {
if(!(isa<GetElementPtrInst>(I)))
continue;
GetElementPtrInst *GEP = cast<GetElementPtrInst>(I);
if(BitCastInst *BI = dyn_cast<BitCastInst>(GEP->getOperand(0))) {
if(Constant *C = dyn_cast<Constant>(BI->getOperand(0))) {
GEP->setOperand(0, ConstantExpr::getBitCast(C, BI->getType()));
}
}
}
}
}
}
示例14: get_hetero_func
/** returns the first calledfunction from paralle_for_hetero */
Function* HeterotbbTransform::get_hetero_func(Module &M, CallSite &CS) {
Function *f = CS.getCalledFunction();
for (Function::iterator BBI = f->begin(), BBE = f->end(); BBI != BBE; ++BBI) {
for (BasicBlock::iterator INSNI = BBI->begin(), INSNE = BBI->end(); INSNI != INSNE; ++INSNI) {
if (isa<CallInst>(INSNI) || isa<InvokeInst>(INSNI)) {
CallSite CI(cast<Instruction>(INSNI));
// CastInst *StrucCast = CastInst::Create(Instruction::BitCast, CI.getArgument(1),
// PointerType::get(Type::getInt8Ty(M.getContext()), 0), "temp_cast", INSNI);
return CI.getCalledFunction();
}
}
}
return NULL;
}
示例15: replaceUndefsWithNull
void Preparer::replaceUndefsWithNull(Module &M) {
ValueSet Replaced;
for (Module::global_iterator GI = M.global_begin(); GI != M.global_end();
++GI) {
if (GI->hasInitializer()) {
replaceUndefsWithNull(GI->getInitializer(), Replaced);
}
}
for (Module::iterator F = M.begin(); F != M.end(); ++F) {
for (Function::iterator BB = F->begin(); BB != F->end(); ++BB) {
for (BasicBlock::iterator Ins = BB->begin(); Ins != BB->end(); ++Ins) {
replaceUndefsWithNull(Ins, Replaced);
}
}
}
}