[LLVMdev] Identify recursion in a call graph

Trevor Harmon Trevor.W.Harmon at nasa.gov
Tue Nov 2 17:04:28 PDT 2010


On Nov 2, 2010, at 12:53 PM, Jeff Kunkel wrote:

> Also, could you write this in a separate pass, and obtain the  
> results from getAnalysis()? I think others would find it useful to  
> discover if a Function may be called recursively.

I've modified the code so that it correctly identifies both direct and  
indirect recursion. I'm now trying to package it up as a patch for the  
LLVM trunk so that others can use it.

Your suggestion to create a new pass for the code is interesting, but  
I'm not sure that this feature warrants an entirely new pass. Maybe  
it's more appropriate to integrate with the existing CallGraph pass by  
adding an isRecursive method to CallGraphNode. For example:

   AU.addRequired<CallGraph>();
   ...
   CallGraphNode* rootNode = getAnalysis<CallGraph>().getRoot();
   if (rootNode->isRecursive()) { ... }

But I have no idea how to write a test case for this. It appears that  
LLVM is not set up for unit tests of individual API calls. Any thoughts?

Trevor




More information about the llvm-dev mailing list