virtual bool runOnModule(Module& M) { AliasAnalysis& aa = this->getAnalysis<AliasAnalysis>(); bool checked = false; errs() << "GatherInterfacePass::runOnModule: " << M.getModuleIdentifier() << "\n"; if (!GatherInterfaceMain.empty()) { checked = true; for (cl::list<std::string>::const_iterator i = GatherInterfaceMain.begin(), e = GatherInterfaceMain.end(); i != e; ++i) { Function* f = M.getFunction(*i); if (f == NULL) { errs() << "Function '" << *i << "' not found, skipping\n"; continue; } if (f->isDeclaration()) { errs() << "Function '" << *i << "' is declaration, skipping\n"; continue; } errs() << "Gathering from: " << *f << "\n"; GatherInterface(*f, this->interface, &aa); } } if (!GatherInterfaceEntry.empty()) { checked = true; ComponentInterface ci; for (cl::list<std::string>::const_iterator i = GatherInterfaceEntry.begin(), e = GatherInterfaceEntry.end(); i != e; ++i) { errs() << "Reading interface from '" << *i << "'..."; if (ci.readFromFile(*i)) { errs() << "success\n"; } else { errs() << "failed\n"; continue; } } for (ComponentInterface::FunctionIterator i = ci.begin(), e = ci.end(); i != e; ++i) { Function* f = M.getFunction(i->first()); if (f == NULL) continue; if (!GatherInterface(*f, this->interface, &aa)) break; } } if (!checked) { GatherInterface(M, this->interface, &aa); } if (GatherInterfaceOutput != "") { proto::ComponentInterface ci; codeInto<ComponentInterface, proto::ComponentInterface> ( this->interface, ci); std::ofstream output(GatherInterfaceOutput.c_str(), std::ios::binary); assert(ci.SerializeToOstream(&output)); output.close(); } return false; }
InternalizePass(): ModulePass(ID) { errs() << "InternalizePass()\n"; for (cl::list<std::string>::const_iterator b = InterfaceInput.begin(), e = InterfaceInput.end(); b != e; ++b) { errs() << "Reading file '" << *b << "'..."; if (interface.readFromFile(*b)) { errs() << "success\n"; } else { errs() << "failed\n"; } } errs() << "Done reading.\n"; }