[llvm-dev] Get instance of CallGraph of a module in the pass

Victor Campos via llvm-dev llvm-dev at lists.llvm.org
Fri Oct 9 07:34:22 PDT 2015


Hi,

you could require the Call Graph pass:

void MyPass::getAnalysisUsage(AnalysisUsage &AU) const {
>   ...
>   AU.addRequired<CallGraphWrapperPass>();
> }


and then get the result at some point in your pass:

CallGraph &CG = getAnalysis<CallGraphWrapperPass>().getCallGraph();


I believe this works for you.

2015-10-09 11:26 GMT-03:00 Riyad Parvez via llvm-dev <
llvm-dev at lists.llvm.org>:

> Hello,
>
> I want an instance of CallGraph in my pass. By looking at -dot-callgraph
> source, I've tried something like this:
>
> CallGraphWrapperPass *CGWP = new CallGraphWrapperPass();
> PM.add(CGWP);
> CallGraph *CG = &CGWP->getCallGraph();
> PM.add(new MyPass(CG));
>
>
> I get the following error:
>
> /home/riyad/installs/llvm-3.7.0/include/llvm/PassSupport.h:95:38: error:
> no matching constructor for initialization of
>       'MyPass'
> Pass *callDefaultCtor() { return new PassName(); }
>
>
> My guess is pass manager needs pass with default constructor. Is there any
> easy way to get instance of call graph in my pass?
>
> Thanks in Advance,
> Riyad
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151009/e3ddec51/attachment.html>


More information about the llvm-dev mailing list