1 //===------- ObjectLinkingLayer.cpp - JITLink backed ORC ObjectLayer ------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
10 #include "llvm/ExecutionEngine/Orc/DebugUtils.h"
11 #include "llvm/Support/MemoryBuffer.h"
13 #define DEBUG_TYPE "orc"
17 char ObjectLinkingLayer::ID
;
19 using BaseObjectLayer
= RTTIExtends
<ObjectLinkingLayer
, ObjectLayer
>;
21 void ObjectLinkingLayer::emit(std::unique_ptr
<MaterializationResponsibility
> R
,
22 std::unique_ptr
<MemoryBuffer
> O
) {
23 assert(O
&& "Object must not be null");
24 MemoryBufferRef ObjBuffer
= O
->getMemBufferRef();
26 if (auto G
= jitlink::createLinkGraphFromObject(
27 ObjBuffer
, getExecutionSession().getSymbolStringPool())) {
28 emit(std::move(R
), std::move(*G
), std::move(O
));
30 R
->getExecutionSession().reportError(G
.takeError());
31 R
->failMaterialization();
36 } // namespace llvm::orc