bool PrintCgTree::runOnModule(Module &M) { #if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR == 4 CallGraph CG; CG.runOnModule(M); CallGraphNode* root = CG.getRoot(); #else CallGraph CG(M); Function* Main = M.getFunction("main"); CallGraphNode* root = Main?CG[Main]:CG.getExternalCallingNode(); #endif Assert(root->getFunction()==Main, ""); errs()<<root->getFunction()->getName()<<"\n"; print_cg(root); return false; }
bool CallGraphCFG::runOnModule(Module &M) { CallGraph *CG = &getAnalysis<CallGraph>(); CallGraphNode *root = CG->getRoot(); if (root == NULL) return true; getDefectList(defectFile, &dl); if (dl.size()==0) return true; for (defectList::iterator dit=dl.begin(); dit != dl.end(); ++dit) { std::string file = dit->first; std::vector<int> lines = dit->second; for (std::vector<int>::iterator lit=lines.begin(); lit != lines.end(); ++lit) { std::cerr << "Mapping defect to BBs " << file << ":" << *lit << "\n"; std::vector<BasicBlock*> tpath; findBBPath(root, tpath, file, *lit); if (tpath.size() == 0) std::cerr << "! unreachable " << file << ":" << *lit << "\n"; else bbpaths->push_back(tpath); } } return false; }