LLVM 20.0.0git
IRCompileLayer.cpp
Go to the documentation of this file.
1//===--------------- IRCompileLayer.cpp - IR Compiling Layer --------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10
11namespace llvm {
12namespace orc {
13
15
17 std::unique_ptr<IRCompiler> Compile)
18 : IRLayer(ES, ManglingOpts), BaseLayer(BaseLayer),
19 Compile(std::move(Compile)) {
20 ManglingOpts = &this->Compile->getManglingOptions();
21}
22
24 std::lock_guard<std::mutex> Lock(IRLayerMutex);
25 this->NotifyCompiled = std::move(NotifyCompiled);
26}
27
28void IRCompileLayer::emit(std::unique_ptr<MaterializationResponsibility> R,
29 ThreadSafeModule TSM) {
30 assert(TSM && "Module must not be null");
31
32 if (auto Obj = TSM.withModuleDo(*Compile)) {
33 {
34 std::lock_guard<std::mutex> Lock(IRLayerMutex);
35 if (NotifyCompiled)
36 NotifyCompiled(*R, std::move(TSM));
37 else
38 TSM = ThreadSafeModule();
39 }
40 BaseLayer.emit(std::move(R), std::move(*Obj));
41 } else {
42 R->failMaterialization();
43 getExecutionSession().reportError(Obj.takeError());
44 }
45}
46
47} // End namespace orc.
48} // End namespace llvm.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
An ExecutionSession represents a running JIT program.
Definition: Core.h:1431
void reportError(Error Err)
Report a error for this execution session.
Definition: Core.h:1566
void emit(std::unique_ptr< MaterializationResponsibility > R, ThreadSafeModule TSM) override
Emit should materialize the given IR.
std::function< void(MaterializationResponsibility &R, ThreadSafeModule TSM)> NotifyCompiledFunction
void setNotifyCompiled(NotifyCompiledFunction NotifyCompiled)
IRCompileLayer(ExecutionSession &ES, ObjectLayer &BaseLayer, std::unique_ptr< IRCompiler > Compile)
Interface for layers that accept LLVM IR.
Definition: Layer.h:67
ExecutionSession & getExecutionSession()
Returns the ExecutionSession for this layer.
Definition: Layer.h:75
Interface for Layers that accept object files.
Definition: Layer.h:133
virtual void emit(std::unique_ptr< MaterializationResponsibility > R, std::unique_ptr< MemoryBuffer > O)=0
Emit should materialize the given IR.
An LLVM Module together with a shared ThreadSafeContext.
decltype(auto) withModuleDo(Func &&F)
Locks the associated ThreadSafeContext and calls the given function on the contained Module.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1856
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858