1 | //===------- ObjectLinkingLayer.cpp - JITLink backed ORC ObjectLayer ------===// |
---|---|
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 | |
9 | #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h" |
10 | #include "llvm/ExecutionEngine/Orc/DebugUtils.h" |
11 | #include "llvm/Support/MemoryBuffer.h" |
12 | |
13 | #define DEBUG_TYPE "orc" |
14 | |
15 | namespace llvm::orc { |
16 | |
17 | char ObjectLinkingLayer::ID; |
18 | |
19 | void ObjectLinkingLayer::emit(std::unique_ptr<MaterializationResponsibility> R, |
20 | std::unique_ptr<MemoryBuffer> O) { |
21 | assert(O && "Object must not be null"); |
22 | MemoryBufferRef ObjBuffer = O->getMemBufferRef(); |
23 | |
24 | if (auto G = jitlink::createLinkGraphFromObject( |
25 | ObjectBuffer: ObjBuffer, SSP: getExecutionSession().getSymbolStringPool())) { |
26 | emit(R: std::move(R), G: std::move(*G), ObjBuf: std::move(O)); |
27 | } else { |
28 | R->getExecutionSession().reportError(Err: G.takeError()); |
29 | R->failMaterialization(); |
30 | return; |
31 | } |
32 | } |
33 | |
34 | } // namespace llvm::orc |
35 |