本文整理汇总了C++中module::iterator::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ iterator::empty方法的具体用法?C++ iterator::empty怎么用?C++ iterator::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类module::iterator
的用法示例。
在下文中一共展示了iterator::empty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findFunctionScopedAllocas
/// findFunctionScopedAllocas - store all allocas that are known to be valid
/// to the end of their function in a set. The current algorithm does this by
/// finding all the allocas in the entry block that are before the first
/// llvm.stacksave call (if any).
///
/// FIXME: There can also be allocas elsewhere that get deallocated at the end
/// of the function but they are pessimistically ignored for now.
///
void ExactCheckOpt::findFunctionScopedAllocas(Module &M) {
for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) {
if (F->empty())
continue;
BasicBlock &BB = F->getEntryBlock();
for (BasicBlock::iterator I = BB.begin(), E = BB.end(); I != E; ++I) {
if (AllocaInst *AI = dyn_cast<AllocaInst>(I)) {
FunctionScopedAllocas.insert(AI);
} else if(CallInst *CI = dyn_cast<CallInst>(I)) {
Function *CalledFunction = CI->getCalledFunction();
if (CalledFunction && CalledFunction->getName() == "llvm.stacksave")
break;
}
}
}
}
示例2: runOnModule
bool TraceBasicBlocks::runOnModule(Module &M) {
Context =&M.getContext();
Function *Main = M.getFunction("main");
if (Main == 0) {
errs() << "WARNING: cannot insert basic-block trace instrumentation"
<< " into a module with no main function!\n";
return false; // No main, no instrumentation!
}
const char* FnName="llvm_trace_basic_block";
Constant *InstrFn = M.getOrInsertFunction (FnName, Type::getVoidTy(*Context),
Type::getInt64Ty(*Context), NULL);
unsigned BBNumber = 0;
for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) {
if(F->empty()) { continue; }
//We insert instrumentation calls in reverse order, because insertion puts them before previous instructions
for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) {
dbgs() << "InsertInstrumentationCall (\"" << BB->getName ()
<< "\", \"" << F->getName() << "\", " << BBNumber << ")\n";
//On Exit we emit the FunRet block
TerminatorInst* TI=BB->getTerminator();
if(TI->getNumSuccessors()==0) {
InsertRetInstrumentationCall(TI,InstrFn);
}
InsertInstrumentationCall (BB, InstrFn, BBNumber);
if(TraceMemory) {
InsertMemoryTracingCall (BB,InstrFn);
}
++BBNumber;
}
//on Entry we emit the FunCall block.
BasicBlock* EntryBlock=&F->getEntryBlock();
InsertInstrumentationCall (EntryBlock, InstrFn, BBTraceStream::FunCallID);
}
// Add the initialization call to main.
InsertProfilingInitCall(Main, "llvm_start_basic_block_tracing");
return true;
}