About LLVM Pass dependency

Hello

I am working on pass which has dependency on multiple passes. Say D1,D2,D3

I used

INITIALIZE_PASS_BEGIN
INITIALIZE_PASS_DEPENDENCY(D1)
INITIALIZE_PASS_DEPENDENCY(D2)
INITIALIZE_PASS_DEPENDENCY(D3)
INITIALIZE_PASS_END.

While running it through opt tool it, I had to specify this D1,D2,D3 pass names

to get this pass executed before my pass.

Is there way, to let llvm pass manager to know execute all dependencies without

having to specify explicitly.?

I suspect i am doing something wrong in my code, May be.

Thanks

Mahesh

Hi Mahesh,

Did you override getAnalysisUsage and require D1, D2 and D3?

void YourPass::getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired();
AU.addRequired();
AU.addRequired();
}

Hi Hongbin

I am not quite familiar with AnalysisUsage, let me correct question a bit.
I have read Writing Pass, All examples that i see here are based on collecting information .i.e Analysis Passes.

I wonder if this applies to Transformation passes also.

e.g.

void MyInliner::getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired(); // Transformation Pass

AU.addRequired(); // Transformation like pass

AU.addRequired(); // Analysis Pass

}

here AnnotateFunctionPass is adding meta information,so technically nothing Functional transformational in module and
not Analysis either.

Would that be right way?

Thanks

Mahesh

AnalysisUsage also apply to transformation pass. For example, a lot of pass requires LCSSA and BreakCriticalEdge, which are transformations.