[llvm] r254434 - Delete the setModule method from the Linker.
Duncan P. N. Exon Smith via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 1 15:03:05 PST 2015
> On 2015-Dec-01, at 10:41, Rafael Espindola via llvm-commits <llvm-commits at lists.llvm.org> wrote:
>
> Author: rafael
> Date: Tue Dec 1 12:41:30 2015
> New Revision: 254434
>
> URL: http://llvm.org/viewvc/llvm-project?rev=254434&view=rev
> Log:
> Delete the setModule method from the Linker.
>
> It was only used from LTO for a debug feature, and LTO can just create
> another linker.
Thanks for the cleanup, this is better.
>
> 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.
>
> Modified:
> llvm/trunk/include/llvm/LTO/LTOCodeGenerator.h
> llvm/trunk/include/llvm/Linker/Linker.h
> llvm/trunk/lib/LTO/LTOCodeGenerator.cpp
> llvm/trunk/lib/Linker/LinkModules.cpp
>
> Modified: llvm/trunk/include/llvm/LTO/LTOCodeGenerator.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LTO/LTOCodeGenerator.h?rev=254434&r1=254433&r2=254434&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/LTO/LTOCodeGenerator.h (original)
> +++ llvm/trunk/include/llvm/LTO/LTOCodeGenerator.h Tue Dec 1 12:41:30 2015
> @@ -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 <string>
> @@ -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<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;
>
> Modified: llvm/trunk/include/llvm/Linker/Linker.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Linker/Linker.h?rev=254434&r1=254433&r2=254434&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/Linker/Linker.h (original)
> +++ llvm/trunk/include/llvm/Linker/Linker.h Tue Dec 1 12:41:30 2015
> @@ -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);
>
> Modified: llvm/trunk/lib/LTO/LTOCodeGenerator.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTOCodeGenerator.cpp?rev=254434&r1=254433&r2=254434&view=diff
> ==============================================================================
> --- llvm/trunk/lib/LTO/LTOCodeGenerator.cpp (original)
> +++ llvm/trunk/lib/LTO/LTOCodeGenerator.cpp Tue Dec 1 12:41:30 2015
> @@ -67,14 +67,14 @@ const char* LTOCodeGenerator::getVersion
> 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();
> }
>
> @@ -114,7 +114,7 @@ bool LTOCodeGenerator::addModule(LTOModu
> 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)
> @@ -130,7 +130,7 @@ void LTOCodeGenerator::setModule(std::un
> 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)
>
> Modified: llvm/trunk/lib/Linker/LinkModules.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=254434&r1=254433&r2=254434&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Linker/LinkModules.cpp (original)
> +++ llvm/trunk/lib/Linker/LinkModules.cpp Tue Dec 1 12:41:30 2015
> @@ -2071,10 +2071,6 @@ bool Linker::linkInModule(Module *Src, u
> return RetCode;
> }
>
> -void Linker::setModule(Module *Dst) {
> - init(Dst, DiagnosticHandler);
> -}
> -
> //===----------------------------------------------------------------------===//
> // LinkModules entrypoint.
> //===----------------------------------------------------------------------===//
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list