summaryrefslogtreecommitdiff
path: root/backend/src/llvm/llvm_to_gen.cpp
diff options
context:
space:
mode:
authorYang, Rong R <rong.r.yang@intel.com>2017-06-22 17:38:55 +0800
committerYang Rong <rong.r.yang@intel.com>2017-06-23 16:04:54 +0800
commit36f6a8b6b956ffed15d100abe677125d4a5aeaed (patch)
tree17353b2825c6fbb8124746bafca9aa9ee196a8f0 /backend/src/llvm/llvm_to_gen.cpp
parentf32e067b2ef32568253cf32fd1bd0eaafe20439c (diff)
downloadbeignet-36f6a8b6b956ffed15d100abe677125d4a5aeaed.tar.gz
GBE: clean llvm module's clone and release.
There are some changes: 1. Clone the module before call LLVMLinkModules2, remove other clones for it. 2. Don't delete module in function llvmToGen. 3. Add a function programNewFromLLVMFile so genProgramNewFromLLVM and buildFromLLVMModule only handle llvm module. Actually, programNewFromLLVMFile is only used by clCreateProgramWithLLVMIntel, and I think it is useless, maybe we could delete it at all. V2: define errDiag beside #if/#endif. Signed-off-by: Yang Rong <rong.r.yang@intel.com> Reviewed-by: Pan Xiuli <xiuli.pan@intel.com>
Diffstat (limited to 'backend/src/llvm/llvm_to_gen.cpp')
-rw-r--r--backend/src/llvm/llvm_to_gen.cpp19
1 files changed, 2 insertions, 17 deletions
diff --git a/backend/src/llvm/llvm_to_gen.cpp b/backend/src/llvm/llvm_to_gen.cpp
index ceefbbb0..8546f730 100644
--- a/backend/src/llvm/llvm_to_gen.cpp
+++ b/backend/src/llvm/llvm_to_gen.cpp
@@ -288,7 +288,7 @@ namespace gbe
dc->process(diagnostic);
}
- bool llvmToGen(ir::Unit &unit, const char *fileName,const void* module,
+ bool llvmToGen(ir::Unit &unit, const void* module,
int optLevel, bool strictMath, int profiling, std::string &errors)
{
std::string errInfo;
@@ -296,23 +296,9 @@ namespace gbe
if (OCL_OUTPUT_LLVM_BEFORE_LINK || OCL_OUTPUT_LLVM_AFTER_LINK || OCL_OUTPUT_LLVM_AFTER_GEN)
o = std::unique_ptr<llvm::raw_fd_ostream>(new llvm::raw_fd_ostream(fileno(stdout), false));
- // Get the module from its file
- llvm::SMDiagnostic Err;
-
Module* cl_mod = NULL;
if (module) {
cl_mod = reinterpret_cast<Module*>(const_cast<void*>(module));
- } else if (fileName){
-#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 39
- llvm::LLVMContext& c = GBEGetLLVMContext();
-#else
- llvm::LLVMContext& c = llvm::getGlobalContext();
-#endif
-#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 36
- cl_mod = parseIRFile(fileName, Err, c).release();
-#else
- cl_mod = ParseIRFile(fileName, Err, c);
-#endif
}
if (!cl_mod) return false;
@@ -335,8 +321,7 @@ namespace gbe
/* Before do any thing, we first filter in all CL functions in bitcode. */
/* Also set unit's pointer size in runBitCodeLinker */
M.reset(runBitCodeLinker(cl_mod, strictMath, unit));
- if (!module)
- delete cl_mod;
+
if (M.get() == 0)
return true;