Skip to content

Commit

Permalink
Fix a multithreaded bug in llvm LazyInitJIT (#3158)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yinghai Lu authored and tqchen committed May 9, 2019
1 parent 9089e19 commit 4ac93a5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/codegen/llvm/llvm_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
Expand Down Expand Up @@ -226,8 +226,10 @@ class LLVMModuleNode final : public runtime::ModuleNode {

private:
void LazyInitJIT() {
CHECK(ee_ == nullptr);
std::lock_guard<std::mutex> lock(mutex_);
if (ee_) {
return;
}
llvm::EngineBuilder builder(std::move(module_));
std::string triple, mcpu, mattr;
llvm::TargetOptions opt;
Expand Down

0 comments on commit 4ac93a5

Please sign in to comment.