[英]Iterating of a simple hello world program with llvm
我是 llvm 框架的新手,我开始非常基础。 有什么比 hello world 更基本的呢? 我想在 main.c 中迭代我的主要 function。 看起来“在函数中迭代 BasicBlock”部分是一个不错的起点”
Function &Func = ...
for (BasicBlock &BB : Func)
// Print out the name of the basic block if it has one, and then the
// number of instructions that it contains
errs() << "Basic block (name=" << BB.getName() << ") has "
<< BB.size() << " instructions.\n";
我应该将Function &Func =
设置为什么? 我想在我的 main.c 文件中查看主要的 function。
当我们讨论这个话题时。 我会将BasicBlock& BB =...
设置为什么?
我的代码。
bool Prereqs::runOnModule(Module &M) {
/* Add your code here */
errs() << "Hi: ";
errs().write_escaped(M.getName()) << '\n';
NumOfFunctions +=10;
outs()<<"get opcode yields: getOpcode()" <<"\n";
Function &Func = main.c;
for (BasicBlock &BB : Func)
// Print out the name of the basic block if it has one, and then the
// // number of instructions that it contains
// errs() << "Basic block (name=" << BB.getName() << ") has "
// << BB.size() << " instructions.\n";
print(M);
return false;
}
文档https://releases.llvm.org/8.0.0/docs/ProgrammersManual.html#basic-inspection-and-traversal-routines
您可能希望将Func
设置为Module::getFunction()的返回值,如果您不知道模块是什么或如何制作模块,请参阅教程。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.