[LLVMdev] getAnalysisIfAvailable<>(...)

Garrison Venn gvenn.cfe.dev at gmail.com
Tue Dec 8 11:11:26 PST 2009


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






More information about the llvm-dev mailing list