在 llvm 中使用 LoopInfoWrapperPass 迭代循环

问题描述 投票:0回答: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"

using namespace 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 循环的程序中遇到杂散错误“�”。有什么问题吗?

llvm llvm-c++-api llvm-4.0
1个回答
0
投票

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

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

© www.soinside.com 2019 - 2024. All rights reserved.