summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2018-05-23 21:27:01 +0000
committerLang Hames <lhames@gmail.com>2018-05-23 21:27:01 +0000
commit4caa2f70ac893befd77471552f1be47a98463669 (patch)
tree4d9d3750c8bb38a30d1ebbde3e990be2bf6e724e /llvm/lib/ExecutionEngine
parent08b682bec1ee742425beed6e17b139aa9018a7e7 (diff)
downloadbcm5719-llvm-4caa2f70ac893befd77471552f1be47a98463669.tar.gz
bcm5719-llvm-4caa2f70ac893befd77471552f1be47a98463669.zip
[LKH] Add a new IRCompileLayer.
llvm-svn: 333127
Diffstat (limited to 'llvm/lib/ExecutionEngine')
-rw-r--r--llvm/lib/ExecutionEngine/Orc/CMakeLists.txt1
-rw-r--r--llvm/lib/ExecutionEngine/Orc/IRCompileLayer.cpp44
-rw-r--r--llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp2
3 files changed, 46 insertions, 1 deletions
diff --git a/llvm/lib/ExecutionEngine/Orc/CMakeLists.txt b/llvm/lib/ExecutionEngine/Orc/CMakeLists.txt
index aaa968f073e..5b94ae990be 100644
--- a/llvm/lib/ExecutionEngine/Orc/CMakeLists.txt
+++ b/llvm/lib/ExecutionEngine/Orc/CMakeLists.txt
@@ -2,6 +2,7 @@ add_llvm_library(LLVMOrcJIT
Core.cpp
ExecutionUtils.cpp
IndirectionUtils.cpp
+ IRCompileLayer.cpp
Legacy.cpp
Layer.cpp
NullResolver.cpp
diff --git a/llvm/lib/ExecutionEngine/Orc/IRCompileLayer.cpp b/llvm/lib/ExecutionEngine/Orc/IRCompileLayer.cpp
new file mode 100644
index 00000000000..0c17f9b7ad4
--- /dev/null
+++ b/llvm/lib/ExecutionEngine/Orc/IRCompileLayer.cpp
@@ -0,0 +1,44 @@
+//===--------------- IRCompileLayer.cpp - IR Compiling Layer --------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
+
+namespace llvm {
+namespace orc {
+
+IRCompileLayer2::IRCompileLayer2(ExecutionSession &ES, ObjectLayer &BaseLayer,
+ CompileFunction Compile)
+ : IRLayer(ES), BaseLayer(BaseLayer), Compile(std::move(Compile)) {}
+
+void IRCompileLayer2::setNotifyCompiled(NotifyCompiledFunction NotifyCompiled) {
+ std::lock_guard<std::mutex> Lock(IRLayerMutex);
+ this->NotifyCompiled = std::move(NotifyCompiled);
+}
+
+void IRCompileLayer2::emit(MaterializationResponsibility R, VModuleKey K,
+ std::unique_ptr<Module> M) {
+ assert(M && "Module must not be null");
+
+ if (auto Obj = Compile(*M)) {
+ {
+ std::lock_guard<std::mutex> Lock(IRLayerMutex);
+ if (NotifyCompiled)
+ NotifyCompiled(K, std::move(M));
+ else
+ M = nullptr;
+ }
+ BaseLayer.emit(std::move(R), std::move(K), std::move(*Obj));
+ } else {
+ R.failMaterialization();
+ getExecutionSession().reportError(Obj.takeError());
+ }
+}
+
+} // End namespace orc.
+} // End namespace llvm.
diff --git a/llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp b/llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp
index c635ab0f883..3e5336ca272 100644
--- a/llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp
@@ -22,7 +22,7 @@ RTDyldObjectLinkingLayer2::RTDyldObjectLinkingLayer2(
void RTDyldObjectLinkingLayer2::emit(MaterializationResponsibility R,
VModuleKey K,
std::unique_ptr<MemoryBuffer> O) {
- assert(O && "Object has already been materialized");
+ assert(O && "Object must not be null");
auto &ES = getExecutionSession();
OpenPOWER on IntegriCloud