LLVM  7.0.0
IRCompileLayer.cpp
Go to the documentation of this file.
1 //===--------------- IRCompileLayer.cpp - IR Compiling Layer --------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
11 
12 namespace llvm {
13 namespace orc {
14 
16  CompileFunction Compile)
17  : IRLayer(ES), BaseLayer(BaseLayer), Compile(std::move(Compile)) {}
18 
20  std::lock_guard<std::mutex> Lock(IRLayerMutex);
21  this->NotifyCompiled = std::move(NotifyCompiled);
22 }
23 
25  std::unique_ptr<Module> M) {
26  assert(M && "Module must not be null");
27 
28  if (auto Obj = Compile(*M)) {
29  {
30  std::lock_guard<std::mutex> Lock(IRLayerMutex);
31  if (NotifyCompiled)
32  NotifyCompiled(K, std::move(M));
33  else
34  M = nullptr;
35  }
36  BaseLayer.emit(std::move(R), std::move(K), std::move(*Obj));
37  } else {
39  getExecutionSession().reportError(Obj.takeError());
40  }
41 }
42 
43 } // End namespace orc.
44 } // End namespace llvm.
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
static sys::Mutex Lock
uint64_t VModuleKey
VModuleKey provides a unique identifier (allocated and managed by ExecutionSessions) for a module add...
Definition: Core.h:40
Definition: BitVector.h:921
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...
Definition: Core.h:124
ExecutionSession & getExecutionSession()
Returns the ExecutionSession for this layer.
Definition: Layer.h:30
void reportError(Error Err)
Report a error for this execution session.
Definition: Core.h:391
Interface for layers that accept LLVM IR.
Definition: Layer.h:24
std::function< Expected< std::unique_ptr< MemoryBuffer > >(Module &)> CompileFunction
void emit(MaterializationResponsibility R, VModuleKey K, std::unique_ptr< Module > M) override
Emit should materialize the given IR.
void setNotifyCompiled(NotifyCompiledFunction NotifyCompiled)
virtual void emit(MaterializationResponsibility R, VModuleKey K, std::unique_ptr< MemoryBuffer > O)=0
Emit should materialize the given IR.
An ExecutionSession represents a running JIT program.
Definition: Core.h:735
IRCompileLayer2(ExecutionSession &ES, ObjectLayer &BaseLayer, CompileFunction Compile)
std::function< void(VModuleKey K, std::unique_ptr< Module >)> NotifyCompiledFunction
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void failMaterialization()
Notify all unfinalized symbols that an error has occurred.
Definition: Core.cpp:653
Interface for Layers that accept object files.
Definition: Layer.h:86