[LLVMdev] getAnalysisIfAvailable<>(...)

Devang Patel devang.patel at gmail.com
Tue Dec 8 13:28:39 PST 2009


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




More information about the llvm-dev mailing list