From 1d06f0bf4e070385fbb6d112318c190fc9aadda8 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 1 Dec 2015 18:41:30 +0000 Subject: [PATCH] Delete the setModule method from the Linker. It was only used from LTO for a debug feature, and LTO can just create another linker. It is pretty odd to have a method to reset the module in the middle of a link. It would make IdentifiedStructTypes inconsistent with the Module for example. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254434 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/LTO/LTOCodeGenerator.h | 4 ++-- include/llvm/Linker/Linker.h | 3 --- lib/LTO/LTOCodeGenerator.cpp | 8 ++++---- lib/Linker/LinkModules.cpp | 4 ---- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/include/llvm/LTO/LTOCodeGenerator.h b/include/llvm/LTO/LTOCodeGenerator.h index 0d3c79bf5e8..c322288a1ae 100644 --- a/include/llvm/LTO/LTOCodeGenerator.h +++ b/include/llvm/LTO/LTOCodeGenerator.h @@ -39,7 +39,6 @@ #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 @@ -49,6 +48,7 @@ namespace llvm { class LLVMContext; class DiagnosticInfo; class GlobalValue; + class Linker; class Mangler; class MemoryBuffer; class TargetLibraryInfo; @@ -171,7 +171,7 @@ private: std::unique_ptr OwnedContext; LLVMContext &Context; std::unique_ptr MergedModule; - Linker IRLinker; + std::unique_ptr IRLinker; std::unique_ptr TargetMach; bool EmitDwarfDebugInfo = false; bool ScopeRestrictionsDone = false; diff --git a/include/llvm/Linker/Linker.h b/include/llvm/Linker/Linker.h index 610b1ddf989..3f6c7b6c694 100644 --- a/include/llvm/Linker/Linker.h +++ b/include/llvm/Linker/Linker.h @@ -85,9 +85,6 @@ public: 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); diff --git a/lib/LTO/LTOCodeGenerator.cpp b/lib/LTO/LTOCodeGenerator.cpp index 931bcf0d23f..37ee7e8c53c 100644 --- a/lib/LTO/LTOCodeGenerator.cpp +++ b/lib/LTO/LTOCodeGenerator.cpp @@ -67,14 +67,14 @@ const char* LTOCodeGenerator::getVersionString() { 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 Context) : OwnedContext(std::move(Context)), Context(*OwnedContext), MergedModule(new Module("ld-temp.o", *OwnedContext)), - IRLinker(MergedModule.get()) { + IRLinker(new Linker(MergedModule.get())) { initializeLTOPasses(); } @@ -114,7 +114,7 @@ bool LTOCodeGenerator::addModule(LTOModule *Mod) { 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 &undefs = Mod->getAsmUndefinedRefs(); for (int i = 0, e = undefs.size(); i != e; ++i) @@ -130,7 +130,7 @@ void LTOCodeGenerator::setModule(std::unique_ptr Mod) { AsmUndefinedRefs.clear(); MergedModule = Mod->takeModule(); - IRLinker.setModule(MergedModule.get()); + IRLinker = make_unique(MergedModule.get()); const std::vector &Undefs = Mod->getAsmUndefinedRefs(); for (int I = 0, E = Undefs.size(); I != E; ++I) diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index f745df56f9a..c57c70e322a 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -2071,10 +2071,6 @@ bool Linker::linkInModule(Module *Src, unsigned Flags, return RetCode; } -void Linker::setModule(Module *Dst) { - init(Dst, DiagnosticHandler); -} - //===----------------------------------------------------------------------===// // LinkModules entrypoint. //===----------------------------------------------------------------------===// -- 2.40.0