首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >LoopPass可加载模块的未定义符号

LoopPass可加载模块的未定义符号
EN

Stack Overflow用户
提问于 2013-05-01 01:23:49
回答 1查看 774关注 0票数 3

我正在按照以下说明构建一个循环传递:http://llvm.org/docs/WritingAnLLVMPass.html Everything工作正常,我多次对函数传递执行它,但是在runOnLoop方法中,每当我调用作为参数传递的循环L的方法时,例如L->begin(),我就会得到以下错误:

符号查找错误: /home/giacomo/llvmcsfv/Debug+Asserts/lib/Acsl.so:未定义符号:_ZNK4llvm8LoopBaseINS_10BasicBlockENS_4LoopEE5beginEv

其中Acsl是可加载模块的名称。如果我删除了runOnPass中的所有指令(调试打印除外),它就可以正常工作(它会打印它),所以问题不是模块。有人知道吗?

这是转换通行证代码:

代码语言:javascript
复制
//===- AcslDCEE.cpp - Acsl Dead Code Elimination -----------------*- C++ -*-===//
//
//         The LLVM Compiler Infrastructure - CSFV Annotation Framework
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements a Dead Code Elimination that uses ACSL annotations
//
//===----------------------------------------------------------------------===//    

#define DEBUG_TYPE "licm"
#include "llvm/Transforms/Scalar.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/AliasSetTracker.h"
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/Analysis/Dominators.h"
#include "llvm/Pass.h"
#include "llvm/IR/Function.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Metadata.h"
#include "llvm/Support/CFG.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetLibraryInfo.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Transforms/Utils/SSAUpdater.h"
#include <algorithm>
using namespace llvm;    

// STATISTIC(AcslNumSunk      , "Number of instructions sunk out of loop");
// STATISTIC(AcslNumHoisted   , "Number of instructions hoisted out of loop");
// STATISTIC(AcslNumMovedLoads, "Number of load insts hoisted or sunk");
// STATISTIC(AcslNumMovedCalls, "Number of call insts hoisted or sunk");
// STATISTIC(AcslNumPromoted  , "Number of memory locations promoted to registers");    

namespace {
struct AcslDCEE: public LoopPass {
  static char ID; // Pass identification, replacement for typeid
  AcslDCEE() :
      LoopPass(ID) {}    

  virtual void getAnalysisUsage(AnalysisUsage &AU) const {
    AU.setPreservesCFG();
    AU.addRequired<DominatorTree>();
    AU.addRequired<LoopInfo>();
    AU.addRequiredID(LoopSimplifyID);
    AU.addRequired<AliasAnalysis>();
    AU.addPreserved<AliasAnalysis>();
    AU.addPreserved("scalar-evolution");
    AU.addPreservedID(LoopSimplifyID);
    AU.addRequired<TargetLibraryInfo>();
  }    

  /**
   * The runOnFunction method must be implemented by your subclass to do the
   * transformation or analysis work of your pass. As usual, a true value
   * should be returned if the function is modified.
   */
  virtual bool runOnLoop(Loop *L, LPPassManager &LPM){
    bool Changed = false;
    LI = &getAnalysis<LoopInfo>();
    AA = &getAnalysis<AliasAnalysis>();
    DT = &getAnalysis<DominatorTree>();    

    TD = getAnalysisIfAvailable<DataLayout>();
    TLI = &getAnalysis<TargetLibraryInfo>();    

    errs() << "before!\n";
    L->begin();
    errs() << "after!\n";
    return Changed;
  }    

  /**
   * The doInitialization method is designed to do simple initialization type
   * of stuff that does not depend on the functions being processed.
   * The doInitialization method call is not scheduled to overlap with any
   * other pass executions.
   */
  // virtual bool doInitialization(Loop *L, LPPassManager &LPM){
  //   errs() << "###Acsl DCEeeeea###\n";
  //   L->dump();
  //   errs() << "uhm...\n";
  //   return LoopPass::doInitialization(L,LPM);
  //   // return true;
  // }    

  // /**
  //  * The doFinalization method is an infrequently used method that is called
  //  * when the pass framework has finished calling runOnFunction for every
  //  * function in the program being compiled.
  //  */
  // virtual bool doFinalization(Module &M) {
  //   DEBUG(errs() << "\n");
  //   return LoopPass::doFinalization(M);
  // }    

  // bool doFinalization() {
  //     DEBUG(errs() << "\n");
  //     return LoopPass::doFinalization();
  //   }    

private:    

  AliasAnalysis *AA;       // Current AliasAnalysis information
  LoopInfo      *LI;       // Current LoopInfo
  DominatorTree *DT;       // Dominator Tree for the current Loop.    

  DataLayout *TD;          // DataLayout for constant folding.
  TargetLibraryInfo *TLI;  // TargetLibraryInfo for constant folding.    

  // State that is updated as we process loops.
  bool Changed;            // Set to true when we change anything.
  BasicBlock *Preheader;   // The preheader block of the current loop...
  Loop *CurLoop;           // The current loop we are working on...
  AliasSetTracker *CurAST; // AliasSet information for the current loop...
  bool MayThrow;           // The current loop contains an instruction which
                           // may throw, thus preventing code motion of
                           // instructions with side effects.
  DenseMap<Loop*, AliasSetTracker*> LoopToAliasSetMap;    

};
} //end of anonymous namespace    

char AcslDCEE::ID = 0;
static RegisterPass<AcslDCEE> X("acsldcee", "acsl dead code elimination");
// INITIALIZE_PASS_BEGIN(AcslDCEE, "acsldcee", "Loop Invariant Code Motion", false, false)
// // INITIALIZE_PASS_DEPENDENCY(DominatorTree)
// INITIALIZE_PASS_DEPENDENCY(LoopInfo)
// // INITIALIZE_PASS_DEPENDENCY(LoopSimplify)
// // INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfo)
// // INITIALIZE_AG_DEPENDENCY(AliasAnalysis)
// INITIALIZE_PASS_END(AcslDCEE, "acsldcee", "Loop Invariant Code Motion", false, false)
EN

回答 1

Stack Overflow用户

发布于 2013-05-03 03:27:17

begin()函数使用错误。错误说明编译器找不到这样的函数。快速查看循环类引用会告诉我,没有一个名为begin的成员函数。

1Loop.html

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16311431

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档