Is it consistent to have a Pass instance's run method's implementation use getAnalysisIfAvailable<AnalysisType>() (vs just using getAnalysis< AnalysisType >) when that same instance's getAnalysisUsage(AnalysisUsage &au) implementation invokes au.addRequired<AnalysisType>()? For example in the implementation of SelectionDAGISel::runOnMachineFunction(...) (called from MachineFunctionPass::runOnFunction(...)): DwarfWriter *DW = getAnalysisIfAvailable<DwarfWriter>(); is used vs: DwarfWriter &DW = getAnalysis<DwarfWriter>(); even though SelectionDAGISel::getAnalysisUsage(AnalysisUsage &AU) sets: AU.addRequired<DwarfWriter>(); Since this occurs in 2.6 and trunk, and this pattern is repeated with other analysis passes, I'm wondering if I'm not understanding something. Thanks in advance Garrison
Hi! If a pass is required then it makes sense to getAnalysis<DwarfWriter>(). getAnalysisIfAvailable<>() is used for cases where a pass want to take advantage of (or fix up) info only *if* it is available. If you prepare a patch to fix getAnalysisifAvailable<>() uses (e.g. DwarfWriter requests you mention below) then I'll apply it. - Devang On Tue, Dec 8, 2009 at 11:11 AM, Garrison Venn <gvenn.cfe.dev at gmail.com> wrote:> Is it consistent to have a Pass instance's run method's implementation use getAnalysisIfAvailable<AnalysisType>() (vs just using getAnalysis< AnalysisType >) when that same instance's getAnalysisUsage(AnalysisUsage &au) implementation invokes au.addRequired<AnalysisType>()? > > For example in the implementation of SelectionDAGISel::runOnMachineFunction(...) (called from MachineFunctionPass::runOnFunction(...)): > > DwarfWriter *DW = getAnalysisIfAvailable<DwarfWriter>(); > > is used vs: > > DwarfWriter &DW = getAnalysis<DwarfWriter>(); > > even though SelectionDAGISel::getAnalysisUsage(AnalysisUsage &AU) sets: > > AU.addRequired<DwarfWriter>(); > > Since this occurs in 2.6 and trunk, and this pattern is repeated with other analysis passes, I'm wondering if I'm not understanding something. > > Thanks in advance > > Garrison > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-- - Devang
Ok, I'll target this, if is not done by then, once I get a better understanding of the LLVM infrastructure. I currently seem to be spending most of my limited time reading LLVM source. Thanks for the clarification. Garrison On Dec 8, 2009, at 16:28, Devang Patel wrote:> Hi! > > If a pass is required then it makes sense to > getAnalysis<DwarfWriter>(). getAnalysisIfAvailable<>() is used for > cases where a pass want to take advantage of (or fix up) info only > *if* it is available. > > If you prepare a patch to fix getAnalysisifAvailable<>() uses (e.g. > DwarfWriter requests you mention below) then I'll apply it. > > - > Devang > > On Tue, Dec 8, 2009 at 11:11 AM, Garrison Venn <gvenn.cfe.dev at gmail.com> wrote: >> Is it consistent to have a Pass instance's run method's implementation use getAnalysisIfAvailable<AnalysisType>() (vs just using getAnalysis< AnalysisType >) when that same instance's getAnalysisUsage(AnalysisUsage &au) implementation invokes au.addRequired<AnalysisType>()? >> >> For example in the implementation of SelectionDAGISel::runOnMachineFunction(...) (called from MachineFunctionPass::runOnFunction(...)): >> >> DwarfWriter *DW = getAnalysisIfAvailable<DwarfWriter>(); >> >> is used vs: >> >> DwarfWriter &DW = getAnalysis<DwarfWriter>(); >> >> even though SelectionDAGISel::getAnalysisUsage(AnalysisUsage &AU) sets: >> >> AU.addRequired<DwarfWriter>(); >> >> Since this occurs in 2.6 and trunk, and this pattern is repeated with other analysis passes, I'm wondering if I'm not understanding something. >> >> Thanks in advance >> >> Garrison >> >> >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> > > > > -- > - > Devang