llvm callgraph generation

Hi

I refer to the call graph generation of llvm

Generally, I use the opt -dot-callgraph to help me to generate the call graph. This method needs the bitcode. I used to use gold-link and the flag save-temps to help me to save the bitcode.

However, is it able to generate the call graph during the compiling/linking time?
For example
Callgraph cg = new Callgraph(&M)
cg.print(filestream)

I would like to write a llvm pass and use the -Xclang -load to run the pass during the compiling/linking time. However, since the call graph is for the context of the whole program rather than a single module. I guess a module pass may not work. Does anyone have ideas?

Regards
Muhui