我很新写LLVM通行证,我想知道如果我要计算我的主函数调用printf()多少次,我应该添加到我的通行证中(作为示例)。通过查找方法调用数
说我有这个超级精彩的主:
#include <stdio.h>
int main() {
printf("hello world\n");
return 0;
}
而且我想我的通行证,看看printf()函数被调用,它被调用的次数(如果它是在某些种类的循环例)。
这是我在我的通行证至今:
namespace {
struct SkeletonPass : public FunctionPass {
static char ID;
SkeletonPass() : FunctionPass(ID) {}
virtual bool runOnFunction(Function &F) {
errs() << "I saw a function called " << F.getName() << "!\n";
errs() << "It uses printf()" << F. //I'd like to write out how many times printf() is used here
return false;
}
};
}
你看过[LLVM程序员手册](http://llvm.org/docs/ProgrammersManual.html)吗? –