Hi,<br><br>I am trying to write an LLVM project, using LLVM 2.9. My passes are defined as follows, where the Pass2 requires Pass1.<br><br>namespace llvm {<br><br style="font-family: times new roman,serif;"><span style="font-family: times new roman,serif;">class BaseClass : public ModulePass {</span><br style="font-family: times new roman,serif;">
<span style="font-family: times new roman,serif;"> // Name for printing</span><br style="font-family: times new roman,serif;"><span style="font-family: times new roman,serif;"> const char* printname;</span><br style="font-family: times new roman,serif;">
<span style="font-family: times new roman,serif;">protected:</span><br style="font-family: times new roman,serif;"><span style="font-family: times new roman,serif;"> BaseClass(char id, const char* name) </span><br style="font-family: times new roman,serif;">
<span style="font-family: times new roman,serif;"> : ModulePass(id),printname(name){ </span><br style="font-family: times new roman,serif;"><span style="font-family: times new roman,serif;"> } </span><br style="font-family: times new roman,serif;">
<span style="font-family: times new roman,serif;">}; </span><br style="font-family: times new roman,serif;"><span style="font-family: times new roman,serif;"> </span><br style="font-family: times new roman,serif;">
<span style="font-family: times new roman,serif;">class Pass1 : public BaseClass {</span><br style="font-family: times new roman,serif;"><span style="font-family: times new roman,serif;">public:</span><br style="font-family: times new roman,serif;">
<span style="font-family: times new roman,serif;"> static char ID;</span><br style="font-family: times new roman,serif;"><span style="font-family: times new roman,serif;"> Pass1() : BaseClass(ID, "pass1") { }</span><br style="font-family: times new roman,serif;">
<span style="font-family: times new roman,serif;"> ~Pass1() { releaseMemory(); }</span><br style="font-family: times new roman,serif;"><span style="font-family: times new roman,serif;"> virtual bool runOnModule(Module &M); </span><br style="font-family: times new roman,serif;">
<span style="font-family: times new roman,serif;"> virtual void getAnalysisUsage(AnalysisUsage &AU) const {</span><br style="font-family: times new roman,serif;"><span style="font-family: times new roman,serif;"> AU.setPreservesAll();</span><br style="font-family: times new roman,serif;">
<span style="font-family: times new roman,serif;"> } </span><br style="font-family: times new roman,serif;"><span style="font-family: times new roman,serif;">};</span><br style="font-family: times new roman,serif;"><span style="font-family: times new roman,serif;">class Pass2 : public BaseClass {</span><br style="font-family: times new roman,serif;">
<span style="font-family: times new roman,serif;">public:</span><br style="font-family: times new roman,serif;"><span style="font-family: times new roman,serif;"> static char ID;</span><br style="font-family: times new roman,serif;">
<span style="font-family: times new roman,serif;"> Pass2() : BaseClass(ID, "pass2") { }</span><br style="font-family: times new roman,serif;"><span style="font-family: times new roman,serif;"> ~Pass2() { releaseMemory(); }</span><br style="font-family: times new roman,serif;">
<br style="font-family: times new roman,serif;"><span style="font-family: times new roman,serif;"> virtual bool runOnModule(Module &M);</span><br style="font-family: times new roman,serif;"><br style="font-family: times new roman,serif;">
<span style="font-family: times new roman,serif;"> virtual void getAnalysisUsage(AnalysisUsage &AU) const {</span><br style="font-family: times new roman,serif;"><span style="font-family: times new roman,serif;"> AU.addRequired<Pass1>();</span><br style="font-family: times new roman,serif;">
<span style="font-family: times new roman,serif;"> AU.setPreservesAll();</span><br style="font-family: times new roman,serif;"><span style="font-family: times new roman,serif;"> }</span><br style="font-family: times new roman,serif;">
<span style="font-family: times new roman,serif;">};</span><br style="font-family: times new roman,serif;"><span style="font-family: times new roman,serif;">} // End llvm namespace</span><br><br>The passes are registered as follows<br>
<br><span style="font-family: times new roman,serif;">using namespace llvm;</span><br style="font-family: times new roman,serif;"><span style="font-family: times new roman,serif;">RegisterPass<Pass1></span><br style="font-family: times new roman,serif;">
<span style="font-family: times new roman,serif;">X("pass1", "Phase1");</span><br style="font-family: times new roman,serif;"><span style="font-family: times new roman,serif;">char Pass1::ID = 0;</span><br>
<br><font size="2"><span style="font-family: times new roman,serif;">bool Pass1::runOnModule(Module &M) {</span><br style="font-family: times new roman,serif;"><span style="font-family: times new roman,serif;"> M.dump();</span><br style="font-family: times new roman,serif;">
<span style="font-family: times new roman,serif;"> return false;</span><br style="font-family: times new roman,serif;"><span style="font-family: times new roman,serif;">}</span><br style="font-family: times new roman,serif;">
<br style="font-family: times new roman,serif;"><span style="font-family: times new roman,serif;">static RegisterPass<Pass2></span><br style="font-family: times new roman,serif;"><span style="font-family: times new roman,serif;">Y("pass2", "Phase 2");</span><br style="font-family: times new roman,serif;">
<span style="font-family: times new roman,serif;">char Pass2::ID = 0;</span><br style="font-family: times new roman,serif;"><br style="font-family: times new roman,serif;"><span style="font-family: times new roman,serif;">bool Pass2::runOnModule (Module &M) {</span><br style="font-family: times new roman,serif;">
<span style="font-family: times new roman,serif;"> M.dump();</span><br style="font-family: times new roman,serif;"><span style="font-family: times new roman,serif;"> return false;</span><br style="font-family: times new roman,serif;">
<span style="font-family: times new roman,serif;">}</span></font><br><br><br>I hit the following assert <br>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.<br>
<br>It works fine if I have pass2 require a different modulePass. But fails when the two module passes share the common parent class.<br><br>Any pointers on whether the code is wrong, or if this is not the right way to do this, would be great.<br>
<br>Thanks,<br>Arushi<br>