/// Returns true on error.
bool linkInModule(Module &Src, unsigned Flags = Flags::None,
const FunctionInfoIndex *Index = nullptr,
- Function *FuncToImport = nullptr);
+ DenseSet<const GlobalValue *> *FuncToImport = nullptr);
static bool linkModules(Module &Dest, Module &Src,
DiagnosticHandlerFunction DiagnosticHandler,
/// Function to import from source module, all other functions are
/// imported as declarations instead of definitions.
- Function *ImportFunction;
+ DenseSet<const GlobalValue *> *ImportFunction;
/// Set to true if the given FunctionInfoIndex contains any functions
/// from this source module, in which case we must conservatively assume
ModuleLinker(Module &DstM, Linker::IdentifiedStructTypeSet &Set, Module &SrcM,
DiagnosticHandlerFunction DiagnosticHandler, unsigned Flags,
const FunctionInfoIndex *Index = nullptr,
- Function *FuncToImport = nullptr)
+ DenseSet<const GlobalValue *> *FuncToImport = nullptr)
: DstM(DstM), SrcM(SrcM), TypeMap(Set), ValMaterializer(this),
DiagnosticHandler(DiagnosticHandler), Flags(Flags), ImportIndex(Index),
ImportFunction(FuncToImport) {
return true;
// Only import the function requested for importing.
auto *SF = dyn_cast<Function>(SGV);
- if (SF && SF == ImportFunction)
+ if (SF && ImportFunction->count(SF))
return true;
// Otherwise no.
return false;
if (isa<Function>(&Src)) {
// For functions, LinkFromSrc iff this is the function requested
// for importing. For variables, decide below normally.
- LinkFromSrc = (&Src == ImportFunction);
+ LinkFromSrc = ImportFunction->count(&Src);
return false;
}
bool Linker::linkInModule(Module &Src, unsigned Flags,
const FunctionInfoIndex *Index,
- Function *FuncToImport) {
+ DenseSet<const GlobalValue *> *FuncToImport) {
ModuleLinker TheLinker(Composite, IdentifiedStructTypes, Src,
DiagnosticHandler, Flags, Index, FuncToImport);
bool RetCode = TheLinker.run();
}
// Link in the specified function.
- if (L.linkInModule(Module, Linker::Flags::None, &Index, F))
+ DenseSet<const GlobalValue *> FunctionsToImport;
+ FunctionsToImport.insert(F);
+ if (L.linkInModule(Module, Linker::Flags::None, &Index,
+ &FunctionsToImport))
report_fatal_error("Function Import: link error");
// Process the newly imported function and add callees to the worklist.
Changed = true;
}
+
return Changed;
}