> bool deleteFunction() { > + // If we're in relinking mode, set linkage of all internal > callees to > + // external. This will allow us extract function, and then - > link > + // everything together
I think 'relink' should always be true. In the case where you are extracting a single function, it will never matter. In the case where you are deleting a function, you certainly want this. As such, I'd just make it unconditional. > + if (reLink) { > + for (Function::iterator B = Named->begin(), BE = Named->end > (); > + B != BE; ++B) { > + for (BasicBlock::iterator I = B->begin(), E = B->end(); > + I != E; ++I) { > + if (CallInst* callInst = dyn_cast<CallInst>(&*I)) { > + Function* Callee = callInst->getCalledFunction(); > + if (Callee && Callee->hasInternalLinkage()) > + Callee->setLinkage(GlobalValue::ExternalLinkage); > + } > + } > + } However, this implementation won't work for functions whose addresses are taken. Why not just scan the function and global var list and mark everything external? Global vars should have the same problem, no? -Chris > + } > + > Named->setLinkage(GlobalValue::ExternalLinkage); > Named->deleteBody(); > assert(Named->isExternal() && "This didn't make the function > external!"); > @@ -113,6 +133,7 @@ > RegisterPass<FunctionExtractorPass> X("extract", "Function > Extractor"); > } > > -ModulePass *llvm::createFunctionExtractionPass(Function *F, bool > deleteFn) { > - return new FunctionExtractorPass(F, deleteFn); > +ModulePass *llvm::createFunctionExtractionPass(Function *F, bool > deleteFn, > + bool relinkCallees) { > + return new FunctionExtractorPass(F, deleteFn, relinkCallees); > } > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits@cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits