#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/StringMap.h"
-#include "llvm/Linker/Linker.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
#include <string>
class LLVMContext;
class DiagnosticInfo;
class GlobalValue;
+ class Linker;
class Mangler;
class MemoryBuffer;
class TargetLibraryInfo;
std::unique_ptr<LLVMContext> OwnedContext;
LLVMContext &Context;
std::unique_ptr<Module> MergedModule;
- Linker IRLinker;
+ std::unique_ptr<Linker> IRLinker;
std::unique_ptr<TargetMachine> TargetMach;
bool EmitDwarfDebugInfo = false;
bool ScopeRestrictionsDone = false;
const FunctionInfoIndex *Index = nullptr,
Function *FuncToImport = nullptr);
- /// \brief Set the composite to the passed-in module.
- void setModule(Module *Dst);
-
static bool LinkModules(Module *Dest, Module *Src,
DiagnosticHandlerFunction DiagnosticHandler,
unsigned Flags = Flags::None);
LTOCodeGenerator::LTOCodeGenerator()
: Context(getGlobalContext()),
MergedModule(new Module("ld-temp.o", Context)),
- IRLinker(MergedModule.get()) {
+ IRLinker(new Linker(MergedModule.get())) {
initializeLTOPasses();
}
LTOCodeGenerator::LTOCodeGenerator(std::unique_ptr<LLVMContext> Context)
: OwnedContext(std::move(Context)), Context(*OwnedContext),
MergedModule(new Module("ld-temp.o", *OwnedContext)),
- IRLinker(MergedModule.get()) {
+ IRLinker(new Linker(MergedModule.get())) {
initializeLTOPasses();
}
assert(&Mod->getModule().getContext() == &Context &&
"Expected module in same context");
- bool ret = IRLinker.linkInModule(&Mod->getModule());
+ bool ret = IRLinker->linkInModule(&Mod->getModule());
const std::vector<const char *> &undefs = Mod->getAsmUndefinedRefs();
for (int i = 0, e = undefs.size(); i != e; ++i)
AsmUndefinedRefs.clear();
MergedModule = Mod->takeModule();
- IRLinker.setModule(MergedModule.get());
+ IRLinker = make_unique<Linker>(MergedModule.get());
const std::vector<const char*> &Undefs = Mod->getAsmUndefinedRefs();
for (int I = 0, E = Undefs.size(); I != E; ++I)
return RetCode;
}
-void Linker::setModule(Module *Dst) {
- init(Dst, DiagnosticHandler);
-}
-
//===----------------------------------------------------------------------===//
// LinkModules entrypoint.
//===----------------------------------------------------------------------===//