klee/0006-llvm38-adapt-to-new-Linker-linkModules.patch

73 lines
2.7 KiB
Diff

From: Jiri Slaby <jirislaby@gmail.com>
Date: Fri, 15 Jun 2018 08:21:39 +0200
Subject: llvm38: adapt to new Linker::linkModules
Patch-mainline: no
LLVM commit d912be98f8eb changed the prototype of linkModules to accept
std::unique_ptr. Adapt to that.
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
---
lib/Module/ModuleUtil.cpp | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/lib/Module/ModuleUtil.cpp b/lib/Module/ModuleUtil.cpp
index ce52819d2579..025b7374fcf9 100644
--- a/lib/Module/ModuleUtil.cpp
+++ b/lib/Module/ModuleUtil.cpp
@@ -343,7 +343,9 @@ static bool linkBCA(object::Archive* archive, Module* composite, std::string& er
KLEE_DEBUG_WITH_TYPE("klee_linker", dbgs() << "Found " << GV->getName() <<
" in " << M->getModuleIdentifier() << "\n");
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ if (Linker::linkModules(*composite, std::unique_ptr<Module>(M)))
+#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
if (Linker::LinkModules(composite, M))
#else
if (Linker::LinkModules(composite, M, Linker::DestroySource, &errorMessage))
@@ -360,8 +362,10 @@ static bool linkBCA(object::Archive* archive, Module* composite, std::string& er
// Link succeed, now clean up
modulesLoadedOnPass++;
KLEE_DEBUG_WITH_TYPE("klee_linker", dbgs() << "Linking succeeded.\n");
-
+// M was owned by linkModules function
+#if LLVM_VERSION_CODE < LLVM_VERSION(3, 8)
delete M;
+#endif
archiveModules[i] = 0;
// We need to recompute the undefined symbols in the composite module
@@ -427,7 +431,9 @@ Module *klee::linkWithLibrary(Module *module,
std::string ErrorMessage;
if (magic == sys::fs::file_magic::bitcode) {
+#if LLVM_VERSION_CODE < LLVM_VERSION(3, 8)
Module *Result = 0;
+#endif
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7)
ErrorOr<std::unique_ptr<Module> > ResultErr =
@@ -445,6 +451,10 @@ Module *klee::linkWithLibrary(Module *module,
ErrorMessage.c_str());
}
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ if (Linker::linkModules(*module, std::move(ResultErr.get()))) {
+ ErrorMessage = "linking error";
+#else
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7)
Result = ResultErr->release();
#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
@@ -456,6 +466,7 @@ Module *klee::linkWithLibrary(Module *module,
ErrorMessage = "linking error";
#else
if (Linker::LinkModules(module, Result, Linker::DestroySource, &ErrorMessage)) {
+#endif
#endif
klee_error("Link with library %s failed: %s", libraryName.c_str(),
ErrorMessage.c_str());
--
2.17.1