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

Riyad Parvez via llvm-dev llvm-dev at lists.llvm.org
Fri Oct 9 07:55:43 PDT 2015


Hi Victor,

Thanks!

One more question, why "llvm.dbg.declare" and "llvm.dbg.value" are also
included in the call graph? These functions are compiler intrinsic for
back-end binary generation.

Riyad

On Fri, Oct 9, 2015 at 10:34 AM, Victor Campos <vhscampos at gmail.com> wrote:

> 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/6f68680e/attachment.html>


More information about the llvm-dev mailing list