Segmentation Fault of BasicCallGraph?

Hi,

I did a little experiment, basically to extract implemented CallGraph
to be a "new" pass with different registered name, and run the "new"
pass, but the result always gives out Segmentation Fault... I am
probably missing
sth?

Implemented another new class,
class BasicCallGraph2 : public ModulePass, public CallGraph {
.....
...
}
The inside code is exact same as BasicCallGraph, except registered
passname to be testcgn and the information of the pass. then after
enabling and run the new pass, on a test.bc file, there is always a
segmentation fault.

0 libLLVM-2.7.so.1 0x00007f5cd87b1d2f
1 libLLVM-2.7.so.1 0x00007f5cd87b238d
2 libpthread.so.0 0x00007f5cd7ba38f0
3 MyPass.so 0x00007f5cd6a538d4
llvm::CallGraphNode::addCalledFunction(llvm::CallSite,
llvm::CallGraphNode*) + 100
4 MyPass.so 0x00007f5cd6a519aa
5 MyPass.so 0x00007f5cd6a52dd1
6 libLLVM-2.7.so.1 0x00007f5cd8432e08
llvm::MPPassManager::runOnModule(llvm::Module&) + 376
7 libLLVM-2.7.so.1 0x00007f5cd8432f2b
llvm::PassManagerImpl::run(llvm::Module&) + 107
8 opt 0x0000000000415d53 main + 2003
9 libc.so.6 0x00007f5cd6c75c4d __libc_start_main + 253
10 opt 0x00000000004095c9
Stack dump:
0. Program arguments: opt -load ../../../Release/lib/MyPass.so -testcgn
1. Running pass 'print out the call grpah node contruction process' on
module '<stdin>'.
Segmentation fault

What is going on? what makes the addCalledFunction failed? I would
really appreciate your answers.......

Thanks,
--freezdom

Shuying Liang wrote:

Hi,

I did a little experiment, basically to extract implemented CallGraph
to be a "new" pass with different registered name, and run the "new"
pass, but the result always gives out Segmentation Fault... I am
probably missing
sth?

Implemented another new class,
class BasicCallGraph2 : public ModulePass, public CallGraph {
.....
...
}
The inside code is exact same as BasicCallGraph, except registered
passname to be testcgn and the information of the pass. then after
enabling and run the new pass, on a test.bc file, there is always a
segmentation fault.

0 libLLVM-2.7.so.1 0x00007f5cd87b1d2f
1 libLLVM-2.7.so.1 0x00007f5cd87b238d
2 libpthread.so.0 0x00007f5cd7ba38f0
3 MyPass.so 0x00007f5cd6a538d4
llvm::CallGraphNode::addCalledFunction(llvm::CallSite,
llvm::CallGraphNode*) + 100
4 MyPass.so 0x00007f5cd6a519aa
5 MyPass.so 0x00007f5cd6a52dd1
6 libLLVM-2.7.so.1 0x00007f5cd8432e08
llvm::MPPassManager::runOnModule(llvm::Module&) + 376
7 libLLVM-2.7.so.1 0x00007f5cd8432f2b
llvm::PassManagerImpl::run(llvm::Module&) + 107
8 opt 0x0000000000415d53 main + 2003
9 libc.so.6 0x00007f5cd6c75c4d __libc_start_main + 253
10 opt 0x00000000004095c9
Stack dump:
0. Program arguments: opt -load ../../../Release/lib/MyPass.so -testcgn
1. Running pass 'print out the call grpah node contruction process' on
module '<stdin>'.
Segmentation fault

What is going on? what makes the addCalledFunction failed? I would
really appreciate your answers.......

Your pass is using multiple inheritance. Have you implemented getAdjustedAnalysisPointer for your pass?

Nick

Hey, Nick..

Well, I had two installation of llvm and forgot to delete the other
one, so by default it called system installed llvm's opt, and rather
than mine.. and the problem is fixed.
But may I ask why implemented getAdjustedAnalysisPointer?