我开始学习llvm api,我写了第一遍.我的目标是打印函数如何调用彼此.
最近我想在显示屏上添加一些循环信息,以查看函数是否可以多次调用.但是当我尝试使用LoopInfo时,我得到了这个编译错误:
llvm[0]: Compiling cfg.cpp for Debug+Asserts build (PIC)
In file included from cfg.cpp:19:
In file included from /home/llvm-lab/llvm/include/llvm/Pass.h:378:
/home/llvm-lab/llvm/include/llvm/PassAnalysisSupport.h:56:37: error:
no member named 'ID' in 'llvm::LoopInfo'
return addRequiredID(PassClass::ID);
^
cfg.cpp:33:10: note: in instantiation of function template
specialization 'llvm::AnalysisUsage::addRequired<llvm::LoopInfo>'
requested here
AU.addRequired<LoopInfo>();
^
1 error generated.
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
#include "llvm/ADT/Statistic.h"
#include "llvm/IR/Function.h"
#include "llvm/Support/raw_ostream.h"
#include "iostream"
#include "llvm/Pass.h"
#include "llvm/IR/InstIterator.h"
#include <llvm/IR/Instructions.h>
#include <llvm/Analysis/LoopInfo.h>
using namespace llvm;
namespace {
struct CFG : public FunctionPass {
static char ID; // Pass …Run Code Online (Sandbox Code Playgroud)