writing an llvm pass

I need to write a pass where I need to find all the predecessors of each leaf node. I think the options that I have is create a sub class of ModulePass or CallGraphSCCPass.

I will need to traverse the call graph bottom up and by the description of CallGraphSCCPass, it seems the Pass to use. The problem that I am facing is from a CallGraphNode, I don’t see any way to get it’s callers.

So I think it will be better to use ModulePass. I start from the root. For each function called from root, I add root to its predecessor list. Then I follow the same using BFS, and for each callee add the caller as well as the predecessors of caller to callee’s predecessor list.

Any views or suggestions on this will be highly appreciated.

Thanks

Vasudev