hfinkel added a comment. I think that the check that you would really want to do is: are the caller and the callee in the same connected component? Can you cache enough information from the CallGraphSCC iteration to check that directly? Repository: rL LLVM http://reviews.llvm.org/D12838