[LLVMdev] 2.9 pass manager asserts "Unable to handle Pass that requires lower level Analysis pass"

Arushi Aggarwal arushi987 at gmail.com
Wed May 18 10:14:49 PDT 2011


Hi,

I am trying to write an LLVM project, using LLVM 2.9. My passes are defined
as follows, where the Pass2 requires Pass1.

namespace llvm {

class BaseClass : public ModulePass {
  // Name for printing
  const char* printname;
protected:
  BaseClass(char id, const char* name)
    : ModulePass(id),printname(name){
  }
};

class Pass1 : public BaseClass {
public:
  static char ID;
  Pass1() : BaseClass(ID, "pass1") { }
  ~Pass1() { releaseMemory(); }
  virtual bool runOnModule(Module &M);
  virtual void getAnalysisUsage(AnalysisUsage &AU) const {
    AU.setPreservesAll();
  }
};
class Pass2 : public BaseClass {
public:
  static char ID;
  Pass2() : BaseClass(ID, "pass2") { }
  ~Pass2() { releaseMemory(); }

  virtual bool runOnModule(Module &M);

  virtual void getAnalysisUsage(AnalysisUsage &AU) const {
    AU.addRequired<Pass1>();
    AU.setPreservesAll();
  }
};
} // End llvm namespace

The passes are registered as follows

using namespace llvm;
RegisterPass<Pass1>
X("pass1", "Phase1");
char Pass1::ID = 0;

bool Pass1::runOnModule(Module &M) {
  M.dump();
  return false;
}

static RegisterPass<Pass2>
Y("pass2", "Phase 2");
char Pass2::ID = 0;

bool Pass2::runOnModule (Module &M) {
  M.dump();
  return false;
}


I hit the following assert
opt: /home/vadve/aggarwa4/llvm29/llvm-2.9/lib/VMCore/PassManager.cpp:1613:
virtual void llvm::MPPassManager::addLowerLevelRequiredPass(llvm::Pass*,
llvm::Pass*): Assertion `(P->getPotentialPassManagerType() <
RequiredPass->getPotentialPassManagerType()) && "Unable to handle Pass that
requires lower level Analysis pass"' failed.

It works fine if I have pass2 require a different modulePass. But fails when
the two module passes share the common parent class.

Any pointers on whether the code is wrong, or if this is not the right way
to do this, would be great.

Thanks,
Arushi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110518/d692c1f4/attachment.html>


More information about the llvm-dev mailing list