1

我正在使用 LoopInfoWrapperPass 来生成 Loopinfo,但是我无法使用 Loopinfo 来迭代我的函数中的循环这里是代码。使用 make 命令时出现构建错误

#include "llvm/Pass.h"
#include "llvm/IR/Function.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
#include "llvm/Analysis/LoopInfo.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"

使用命名空间 llvm;

namespace {
  struct SkeletonPass : public FunctionPass {
        static char ID;
        SkeletonPass() : FunctionPass(ID) {}

        void getAnalysisUsage(AnalysisUsage &AU) const override {
          AU.setPreservesCFG();
          AU.addRequired<LoopInfoWrapperPass>();
        }

        virtual bool runOnFunction(Function &F){
          LoopInfo &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
          for( LoopInfo::iterator i = LI.begin(), e=LI.end(); i != e; ++i){
            //some code here
            }        
        return false;
        }
  }
}

我在for循环行的程序中收到一个杂散错误'\ 342',任何人都可以提前识别问题

4

1 回答 1

0

我知道已经晚了,但万一有人遇到同样的问题。

您是否复制粘贴了 for 循环行?这可能是导致问题的原因。如果是这样,请删除并添加回导致问题的字母。

于 2019-06-16T05:49:16.853 回答