本文整理汇总了C++中llvm::Function::getEntryBlock方法的典型用法代码示例。如果您正苦于以下问题:C++ Function::getEntryBlock方法的具体用法?C++ Function::getEntryBlock怎么用?C++ Function::getEntryBlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类llvm::Function
的用法示例。
在下文中一共展示了Function::getEntryBlock方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runOnFunction
void AstBackEnd::runOnFunction(llvm::Function& fn)
{
grapher.reset(new AstGrapher);
// Before doing anything, create statements for blocks in reverse post-order. This ensures that values exist
// before they are used. (Post-order would try to use statements before they were created.)
for (BasicBlock* block : ReversePostOrderTraversal<BasicBlock*>(&fn.getEntryBlock()))
{
grapher->createRegion(*block, *output->basicBlockToStatement(*block));
}
// Identify loops, then visit basic blocks in post-order. If the basic block if the head
// of a cyclic region, process the loop. Otherwise, if the basic block is the start of a single-entry-single-exit
// region, process that region.
auto& domTreeWrapper = getAnalysis<DominatorTreeWrapperPass>(fn);
domTree = &domTreeWrapper.getDomTree();
postDomTree->recalculate(fn);
RootedPostDominatorTree::treeFromIncompleteTree(fn, postDomTree);
// Traverse graph in post-order. Try to detect regions with the post-dominator tree.
// Cycles are only considered once.
for (BasicBlock* entry : post_order(&fn.getEntryBlock()))
{
BasicBlock* postDominator = entry;
while (postDominator != nullptr)
{
AstGraphNode* graphNode = grapher->getGraphNodeFromEntry(postDominator);
BasicBlock* exit = graphNode->hasExit()
? graphNode->getExit()
: postDominatorOf(*postDomTree, *postDominator);
RegionType region = isRegion(*entry, exit);
if (region == Acyclic)
{
runOnRegion(fn, *entry, exit);
}
else if (region == Cyclic)
{
runOnLoop(fn, *entry, exit);
}
if (!domTree->dominates(entry, exit))
{
break;
}
postDominator = exit;
}
}
Statement* bodyStatement = grapher->getGraphNodeFromEntry(&fn.getEntryBlock())->node;
output->setBody(bodyStatement);
}
示例2: runOnFunction
bool IndependentBlocks::runOnFunction(llvm::Function &F) {
bool Changed = false;
RI = &getAnalysis<RegionInfoPass>().getRegionInfo();
LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
SD = &getAnalysis<ScopDetection>();
SE = &getAnalysis<ScalarEvolution>();
AllocaBlock = &F.getEntryBlock();
DEBUG(dbgs() << "Run IndepBlock on " << F.getName() << '\n');
for (const Region *R : *SD) {
Changed |= createIndependentBlocks(R);
Changed |= eliminateDeadCode(R);
// This may change the RegionTree.
if (!DisableIntraScopScalarToArray || !PollyModelPHINodes)
Changed |= splitExitBlock(const_cast<Region *>(R));
}
DEBUG(dbgs() << "Before Scalar to Array------->\n");
DEBUG(F.dump());
if (!DisableIntraScopScalarToArray || !PollyModelPHINodes)
for (const Region *R : *SD)
Changed |= translateScalarToArray(R);
DEBUG(dbgs() << "After Independent Blocks------------->\n");
DEBUG(F.dump());
verifyAnalysis();
return Changed;
}
示例3: visitBasicBlock
std::vector<llvm::BasicBlock*> BasicBlockSorter::sortBasicBlocks(llvm::Function &function)
{
std::vector<llvm::BasicBlock*> ret;
std::set<llvm::BasicBlock*> visited;
llvm::BasicBlock &entryBlock = function.getEntryBlock();
visitBasicBlock(ret, visited, &entryBlock);
return ret;
}