[LLVMdev] Use information generated by existing passes into new pass

Duncan Sands baldrick at free.fr
Mon Oct 22 05:37:32 PDT 2012

Hi Sunil,

> I want to ask is that can we use the information generated by existing passes
> into a new pass? If yes, then how ?
> For example -loops gives the natural loop information, so can we use this
> information into new pass by calling it.

in your pass's getAnalysisUsage method you use addRequired to specify that you
need a particular analysis, for example

     void MyPass::getAnalysisUsage(AnalysisUsage &AU) const {

Then, to get hold of the analysis when your pass is being run, you can use
getAnalysis<LoopInfo>() .

Ciao, Duncan.

More information about the llvm-dev mailing list