[llvm-dev] LLVM - getAnalysisUsage()

Mehdi Amini via llvm-dev llvm-dev at lists.llvm.org
Fri Jan 22 09:24:44 PST 2016


> On Jan 21, 2016, at 9:05 PM, Syed Rafiul Hussain via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> Hi,
> 
> I am using llvm-3.8 for my project. Following is my getAnalysisUsage() method:
> 
> virtual void getAnalysisUsage(AnalysisUsage &AU) const override
> {
>   AU.setPreservesAll();
>   AU.addRequired<X>();
>   AU.addRequired<Y>();
>   AU.addRequired<Z>();
> }
> 
> Now, if I call getAnalysis<X>(*F), instead of invoking just the X
> pass, all the passes, i.e., X, Y and Z are being invoked. Could anyone
> help me in this regard?

This is expected. With the current pass manager, the scheduling is done upfront. The “addRequired” directive tells the pass manager that before even starting to run your pass, it needs to schedule X, Y, and Z. 
They will run even without the call to  getAnalysis<X>(*F). The new pass manager (not complete yet but almost) will change that.

When running your pass with opt, you can add —debug-pass=Structure to see what the scheduling is.

I hope I didn’t misunderstand your question.

— 
Mehdi



More information about the llvm-dev mailing list