Error: Verify if there is a pass dependency cycle

Hi everyone,

I write a new FunctionPass which wants to use pass PostDominatorTree, so I
implement the next function:

void getAnalysisUsage(AnalysisUsage &AU) const {


Then I get PDT through the next statement:

PostDominatorTree *PDT = &getAnalysis();

My code can be successfully compiled. However, I encounter the next error when I ran the code:

Pass ‘Unnamed pass: implement Pass::getPassName()’ is not initialized.
Verify if there is a pass dependency cycle.
Required Passes:

I used llvm-3.4. Any comments are welcome. Thanks!


You need to initialize your pass with:

INITIALIZE_PASS_BEGIN(YourPass, “your-pass”, “Your Pass”, /cfgonly=/false, /analysis=/false)


INITIALIZE_PASS_END(YourPass, “your-pass”, “Your Pass”, /cfgonly=/false, /analysis=/false)

So as to both register your pass, and have PostDominatorTreeWrapperPass (which is the Analysis pass in charge of creating the PostDominatorTree) initialized before your pass.

It also give a pretty name to YourPass: “Your Pass”
And add an option to opt to run it: “-your-pass”

Yes, I forgot to initialize my pass. Thank you very much.