diff options
author | Yang Rong <rong.r.yang@intel.com> | 2015-02-12 16:29:39 +0800 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@intel.com> | 2015-02-12 18:59:47 +0800 |
commit | 7c21daf4d04c6ad3fbca040b1165c08f7b40d179 (patch) | |
tree | 6c45c02bbaba8fbd4fb537cfdd7456f1dc3b8c81 | |
parent | 957b20b4130a7611b637436dcec5c8e15f21dccf (diff) |
Use llvm-c's LLVMLinkModules instead of llvm::Linker::LinkModules.
llvm::Linker::LinkModules's define will be changed in llvm3.6, and LLVMLinkModules'
define is more stable, so use LLVMLinkModules to link.
Signed-off-by: Yang Rong <rong.r.yang@intel.com>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
-rw-r--r-- | backend/src/backend/gen_program.cpp | 22 | ||||
-rw-r--r-- | backend/src/llvm/llvm_bitcode_link.cpp | 18 |
2 files changed, 14 insertions, 26 deletions
diff --git a/backend/src/backend/gen_program.cpp b/backend/src/backend/gen_program.cpp index 2e391e1e..621a42b1 100644 --- a/backend/src/backend/gen_program.cpp +++ b/backend/src/backend/gen_program.cpp @@ -33,12 +33,7 @@ #include "llvm/IR/Module.h" #include "llvm/IR/DataLayout.h" #endif /* LLVM_VERSION_MINOR <= 2 */ - -#if LLVM_VERSION_MINOR >= 5 -#include "llvm/Linker/Linker.h" -#else -#include "llvm/Linker.h" -#endif +#include "llvm-c/Linker.h" #include "llvm/Transforms/Utils/Cloning.h" #include "llvm/Bitcode/ReaderWriter.h" #include "llvm/Support/raw_ostream.h" @@ -371,22 +366,19 @@ namespace gbe { { #ifdef GBE_COMPILER_AVAILABLE using namespace gbe; - std::string errMsg; + char* errMsg; if(((GenProgram*)dst_program)->module == NULL){ ((GenProgram*)dst_program)->module = llvm::CloneModule((llvm::Module*)((GenProgram*)src_program)->module); errSize = 0; }else{ llvm::Module* src = (llvm::Module*)((GenProgram*)src_program)->module; llvm::Module* dst = (llvm::Module*)((GenProgram*)dst_program)->module; - llvm::Linker::LinkModules( dst, - src, - llvm::Linker::PreserveSource, - &errMsg); - if (errMsg.c_str() != NULL) { + + if (LLVMLinkModules(wrap(dst), wrap(src), LLVMLinkerPreserveSource, &errMsg)) { if (err != NULL && errSize != NULL && stringSize > 0u) { - if(errMsg.length() < stringSize ) - stringSize = errMsg.length(); - strcpy(err, errMsg.c_str()); + if(strlen(errMsg) < stringSize ) + stringSize = strlen(errMsg); + strcpy(err, errMsg); err[stringSize+1] = '\0'; } } diff --git a/backend/src/llvm/llvm_bitcode_link.cpp b/backend/src/llvm/llvm_bitcode_link.cpp index d3058d6c..8eb6dd52 100644 --- a/backend/src/llvm/llvm_bitcode_link.cpp +++ b/backend/src/llvm/llvm_bitcode_link.cpp @@ -38,11 +38,7 @@ #include "sys/cvar.hpp" #include "src/GBEConfig.h" #include "llvm/llvm_gen_backend.hpp" -#if LLVM_VERSION_MINOR >= 5 -#include "llvm/Linker/Linker.h" -#else -#include "llvm/Linker.h" -#endif +#include "llvm-c/Linker.h" using namespace llvm; @@ -110,10 +106,10 @@ namespace gbe if (!newMF) { newMF = src.getFunction(fnName); if (!newMF) { - printf("Can not find the lib: %s\n", fnName.c_str()); - return false; + printf("Can not find the lib: %s\n", fnName.c_str()); + return false; } - fromSrc = true; + fromSrc = true; } std::string ErrInfo;// = "Not Materializable"; @@ -226,10 +222,10 @@ namespace gbe /* We use beignet's bitcode as dst because it will have a lot of lazy functions which will not be loaded. */ - std::string errorMsg; - if(Linker::LinkModules(clonedLib, mod, Linker::DestroySource, &errorMsg)) { + char* errorMsg; + if(LLVMLinkModules(wrap(clonedLib), wrap(mod), LLVMLinkerDestroySource, &errorMsg)) { delete clonedLib; - printf("Fatal Error: link the bitcode error:\n%s\n", errorMsg.c_str()); + printf("Fatal Error: link the bitcode error:\n%s\n", errorMsg); return NULL; } |