diff options
| -rw-r--r-- | llvm/docs/ReleaseNotes.rst | 4 | ||||
| -rw-r--r-- | llvm/include/llvm-c/Linker.h | 14 | ||||
| -rw-r--r-- | llvm/include/llvm/Linker/Linker.h | 4 | ||||
| -rw-r--r-- | llvm/lib/Linker/LinkModules.cpp | 34 | ||||
| -rw-r--r-- | llvm/unittests/Linker/LinkModulesTest.cpp | 24 | 
5 files changed, 3 insertions, 77 deletions
diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst index b712b955af0..cf86f445c87 100644 --- a/llvm/docs/ReleaseNotes.rst +++ b/llvm/docs/ReleaseNotes.rst @@ -35,11 +35,13 @@ Non-comprehensive list of changes in this release  =================================================  * .. note about autoconf build having been removed. -* .. note about C API functions LLVMLinkModules, LLVMParseBitcode, +* .. note about C API functions LLVMParseBitcode,     LLVMParseBitcodeInContext, LLVMGetBitcodeModuleInContext and     LLVMGetBitcodeModule having been removed. LLVMGetTargetMachineData has been     removed (use LLVMGetDataLayout instead). +* The C API function LLVMLinkModules has been removed. +  .. NOTE     For small 1-3 sentence descriptions, just add an entry at the end of     this list. If your description won't fit comfortably in one bullet diff --git a/llvm/include/llvm-c/Linker.h b/llvm/include/llvm-c/Linker.h index 4d9bd46a259..d02c37f94c8 100644 --- a/llvm/include/llvm-c/Linker.h +++ b/llvm/include/llvm-c/Linker.h @@ -28,20 +28,6 @@ typedef enum {  } LLVMLinkerMode;  /* Links the source module into the destination module. The source module is - * damaged. The only thing that can be done is destroy it. Optionally returns a - * human-readable description of any errors that occurred in linking. OutMessage - * must be disposed with LLVMDisposeMessage. The return value is true if an - * error occurred, false otherwise. - * - * Note that the linker mode parameter \p Unused is no longer used, and has - * no effect. - * - * This function is deprecated. Use LLVMLinkModules2 instead. - */ -LLVMBool LLVMLinkModules(LLVMModuleRef Dest, LLVMModuleRef Src, -                         LLVMLinkerMode Unused, char **OutMessage); - -/* Links the source module into the destination module. The source module is   * destroyed.   * The return value is true if an error occurred, false otherwise.   * Use the diagnostic handler to get any diagnostic message. diff --git a/llvm/include/llvm/Linker/Linker.h b/llvm/include/llvm/Linker/Linker.h index 7aa4cb6a41a..c83298c9c72 100644 --- a/llvm/include/llvm/Linker/Linker.h +++ b/llvm/include/llvm/Linker/Linker.h @@ -51,10 +51,6 @@ public:                      DenseSet<const GlobalValue *> *FunctionsToImport = nullptr,                      DenseMap<unsigned, MDNode *> *ValIDToTempMDMap = nullptr); -  /// This exists to implement the deprecated LLVMLinkModules C api. Don't use -  /// for anything else. -  bool linkInModuleForCAPI(Module &Src); -    static bool linkModules(Module &Dest, std::unique_ptr<Module> Src,                            unsigned Flags = Flags::None); diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp index b96a6f42705..f17d5371b0e 100644 --- a/llvm/lib/Linker/LinkModules.cpp +++ b/llvm/lib/Linker/LinkModules.cpp @@ -557,11 +557,6 @@ bool Linker::linkInModule(std::unique_ptr<Module> Src, unsigned Flags,    return ModLinker.run();  } -bool Linker::linkInModuleForCAPI(Module &Src) { -  ModuleLinker ModLinker(Mover, Src, 0, nullptr, nullptr); -  return ModLinker.run(); -} -  bool Linker::linkInMetadata(Module &Src,                              DenseMap<unsigned, MDNode *> *ValIDToTempMDMap) {    SetVector<GlobalValue *> ValuesToLink; @@ -592,35 +587,6 @@ bool Linker::linkModules(Module &Dest, std::unique_ptr<Module> Src,  // C API.  //===----------------------------------------------------------------------===// -static void diagnosticHandler(const DiagnosticInfo &DI, void *C) { -  auto *Message = reinterpret_cast<std::string *>(C); -  raw_string_ostream Stream(*Message); -  DiagnosticPrinterRawOStream DP(Stream); -  DI.print(DP); -} - -LLVMBool LLVMLinkModules(LLVMModuleRef Dest, LLVMModuleRef Src, -                         LLVMLinkerMode Unused, char **OutMessages) { -  Module *D = unwrap(Dest); -  LLVMContext &Ctx = D->getContext(); - -  LLVMContext::DiagnosticHandlerTy OldDiagnosticHandler = -      Ctx.getDiagnosticHandler(); -  void *OldDiagnosticContext = Ctx.getDiagnosticContext(); -  std::string Message; -  Ctx.setDiagnosticHandler(diagnosticHandler, &Message, true); - -  Linker L(*D); -  Module *M = unwrap(Src); -  LLVMBool Result = L.linkInModuleForCAPI(*M); - -  Ctx.setDiagnosticHandler(OldDiagnosticHandler, OldDiagnosticContext, true); - -  if (OutMessages && Result) -    *OutMessages = strdup(Message.c_str()); -  return Result; -} -  LLVMBool LLVMLinkModules2(LLVMModuleRef Dest, LLVMModuleRef Src) {    Module *D = unwrap(Dest);    std::unique_ptr<Module> M(unwrap(Src)); diff --git a/llvm/unittests/Linker/LinkModulesTest.cpp b/llvm/unittests/Linker/LinkModulesTest.cpp index 322a44f8aaf..10a89f39869 100644 --- a/llvm/unittests/Linker/LinkModulesTest.cpp +++ b/llvm/unittests/Linker/LinkModulesTest.cpp @@ -202,30 +202,6 @@ TEST_F(LinkModuleTest, TypeMerge) {              M1->getNamedGlobal("t2")->getType());  } -TEST_F(LinkModuleTest, CAPISuccess) { -  std::unique_ptr<Module> DestM(getExternal(Ctx, "foo")); -  std::unique_ptr<Module> SourceM(getExternal(Ctx, "bar")); -  char *errout = nullptr; -  LLVMBool result = LLVMLinkModules(wrap(DestM.get()), wrap(SourceM.get()), -                                    LLVMLinkerDestroySource, &errout); -  EXPECT_EQ(0, result); -  EXPECT_EQ(nullptr, errout); -  // "bar" is present in destination module -  EXPECT_NE(nullptr, DestM->getFunction("bar")); -} - -TEST_F(LinkModuleTest, CAPIFailure) { -  // Symbol clash between two modules -  std::unique_ptr<Module> DestM(getExternal(Ctx, "foo")); -  std::unique_ptr<Module> SourceM(getExternal(Ctx, "foo")); -  char *errout = nullptr; -  LLVMBool result = LLVMLinkModules(wrap(DestM.get()), wrap(SourceM.get()), -                                    LLVMLinkerDestroySource, &errout); -  EXPECT_EQ(1, result); -  EXPECT_STREQ("Linking globals named 'foo': symbol multiply defined!", errout); -  LLVMDisposeMessage(errout); -} -  TEST_F(LinkModuleTest, NewCAPISuccess) {    std::unique_ptr<Module> DestM(getExternal(Ctx, "foo"));    std::unique_ptr<Module> SourceM(getExternal(Ctx, "bar"));  | 

