Segmentation fault when traverse call graph

Dear everyone,

I want to traverse call graph, but I have some trouble .

In my pass MyPass which need to traverse call graph, I firstly added the CallGraph analysis to the pass requirements by


My pass MyPass then will be added to a pass manager by

manager.add(new MyPass());

and then I want to traverse the call graph such as:

CallGraph CG = this->getAnalysis;
for (CallGraph::const_iterator i = CG.begin(); i != CG.end(); ++i) {


However, I encountered a segmentation fault with the next core dump information. What should I do?

llvm::PassInfo::createPass() const + 4

I recall having a similar problem while coding my own special-purpose "opt". My guess: try adding the following lines before your pass is inserted into the PassManager:

     PassRegistry &Registry = *PassRegistry::getPassRegistry();

You might require other library initializations. Have a look at the "opt" source code.

Yes, you are right. I have solved this problem according to your instruction.

Thank you very much.

2013/12/3 Pablo Barrio <>