Andrei Alvares
2009-Aug-13 17:21 UTC
[LLVMdev] CallGraph - Dominators and Loop Information
Hello everyone, Can LLVM calculate DominatorTree and LoopInfo for call graphs? For example, I need to know if an edge (function1->function2) is a backedge. If there was a DominatorTree for call graphs that would be easy. Since I haven't found, I've copied the algorithm FindFunctionBackedges in BasicBlockUtils.cpp and modified it to use call graphs. Unfortunately, since the call graphs are not reducible, the algorithm does not find backedges correctly. It finds backedges where it shouldn't. Also, I need to know if a function in a call graph is a loop head. If a loop exists, which functions belongs to this loop. If the above algorithm works (to find backedges), finding loop information should be feasible. Also, given a function in a call graph, is it possible to find its predecessors? I mean, I can find them by myself, by previously build a list, but it would be great to have a pred_begin and pred_end for call graph functions. Is there such a thing? Best regards, Andrei