[LLVMdev] Do all user-written passes have to be run through a PassManager object (called from outside the LLVM infrastructure)?

Gai, Jiading jgai at illinois.edu
Thu Jan 16 09:44:31 PST 2014


I have written several passes that have no pre-requisites for any 
previous LLVM native passes prior to my own. For those passes, I have verified that at 
least the following two approaches are equivalent in terms of executing
those self-written passes and getting the correct results:

                        #if METHOD_1
                             PassManager PM;
                             PM.add(new Analyzeind(F));
                             PM.run(*M);
                        #else //METHOD_2
                             AnalyzeKind *abk = new AnalyzeKind(F);
                             abk->runOnFunction(*F);
                        #endif

However, I found that if my own pass has requirements, e.g.   

                         AU.addRequired<DominatorTree>();
                         AU.addPreserved<DominatorTree>();

Then, only method 1 can work; The following error msg was what 
I got from using method 2:

LLVM/llvm-3.3.src/include/llvm/PassAnalysisSupport.h:200: AnalysisType& llvm::Pass::getAnalysis() const [with AnalysisType = llvm::DominatorTree]: Assertion `Resolver && "Pass has not been inserted into a PassManager object!"' failed.

Note: I have added "initializeDominatorTreePass(*PassRegistry::getPassRegistry());"
      to the constructor of my own pass; 



More information about the llvm-dev mailing list