Gai, Jiading
2014-Jan-16 17:44 UTC
[LLVMdev] Do all user-written passes have to be run through a PassManager object (called from outside the LLVM infrastructure)?
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;
John Criswell
2014-Jan-16 19:29 UTC
[LLVMdev] Do all user-written passes have to be run through a PassManager object (called from outside the LLVM infrastructure)?
On 1/16/14 11:44 AM, Gai, Jiading wrote:> 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:I don't know if you *must* run all passes via a PassManager, but I think you should. That's how passes are designed to work, and running them through a PassManager provides some future-proofing benefits (e.g., if you add a prerequisite analysis pass to one of your passes, it will "just work"). -- John T.
jiading
2014-Jan-17 00:20 UTC
[LLVMdev] Do all user-written passes have to be run through a PassManager object (called from outside the LLVM infrastructure)?
Thanks John. Out of curiosity, I wonder if it's possible to summarize the LLVMpass-specific design patterns. I.e., the software engineering techniques that were used to design/implement the LLVM Pass Infrastructure. Equivalently, this may also answer the question "Why is the code this way". This visibility can improve understanding and that is likely to improve quality as more developers are better informed.
Gai, Jiading
2014-Jan-17 00:21 UTC
[LLVMdev] Do all user-written passes have to be run through a PassManager object (called from outside the LLVM infrastructure)?
Thanks John. Out of curiosity, I wonder if it's possible to summarize the LLVMpass-specific design patterns. I.e., the software engineering techniques that were used to design/implement the LLVM Pass Infrastructure. Equivalently, this may also answer the question "Why is the code this way". This visibility can improve understanding and that is likely to improve quality as more developers are better informed. ________________________________________ From: Criswell, John T Sent: Thursday, January 16, 2014 1:29 PM To: Gai, Jiading; llvmdev at cs.uiuc.edu Subject: Re: [LLVMdev] Do all user-written passes have to be run through a PassManager object (called from outside the LLVM infrastructure)? On 1/16/14 11:44 AM, Gai, Jiading wrote:> 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:I don't know if you *must* run all passes via a PassManager, but I think you should. That's how passes are designed to work, and running them through a PassManager provides some future-proofing benefits (e.g., if you add a prerequisite analysis pass to one of your passes, it will "just work"). -- John T.
Possibly Parallel Threads
- [LLVMdev] Do all user-written passes have to be run through a PassManager object (called from outside the LLVM infrastructure)?
- [LLVMdev] How to print a list of used LLVM APIs in a given open source project?
- Has the work in this talk been pushed: "Better C++ debugging using Clang Modules in LLDB"?
- [LLVMdev] `MDNode *getLoopID () const` missing from LoopInfo.h
- [LLVMdev] PassManager Dependence Question