[LLVMdev] Get the call graph SCCs from a function pass

Török Edwin edwintorok at gmail.com
Sun May 10 11:26:54 PDT 2009


On 2009-05-10 21:18, Nick Johnson wrote:
> On 5/10/09, Török Edwin <edwintorok at gmail.com> wrote:
>   
>> On 2009-05-10 20:11, Nick Johnson wrote:
>>  > Hello,
>>  >
>>  > I'm writing a Function Pass.  This function pass needs access to the
>>  > CallGraph and CallGraph SCCs.  Is there any way I can get CallGraph
>>  > information without changing my pass to a CallGraphSCCPass ?
>>
>>
>> Does getAnalysis<CallGraph>() work?
>>
>>     
> AFAIK, it's not a pass.
>
>   

It is, see lib/Analysis/IPA/CallGraph.cpp:

static RegisterAnalysisGroup<CallGraph> X("Call Graph");
static RegisterPass<BasicCallGraph>
Y("basiccg", "Basic CallGraph Construction", false, true);
static RegisterAnalysisGroup<CallGraph, true> Z(Y);

I know that using getAnalysis<CallGraph> works in a ModulePass, but
never tried it in a FunctionPass.

>>  But I'm not sure if using a FunctionPass to access Callgraph data is a
>>  good idea, transformations can
>>  change it (for example dead code elimination can remove edges).
>>
>>     
> I'm just using it to interpret profiling information correctly; in
> that respect, it doesn't matter if transformations change the IR, so
> long as the CallGraph data reflects the IR against which profiling was
> done.
>   

Ok.

Best regards,
--Edwin



More information about the llvm-dev mailing list