aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp
blob: 9bc0aa89c35339d3bf1a7ba2796d50e0f47f6332 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//===------- ObjectLinkingLayer.cpp - JITLink backed ORC ObjectLayer ------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
#include "llvm/ExecutionEngine/Orc/DebugUtils.h"
#include "llvm/Support/MemoryBuffer.h"

#define DEBUG_TYPE "orc"

namespace llvm::orc {

char ObjectLinkingLayer::ID;

void ObjectLinkingLayer::emit(std::unique_ptr<MaterializationResponsibility> R,
                              std::unique_ptr<MemoryBuffer> O) {
  assert(O && "Object must not be null");
  MemoryBufferRef ObjBuffer = O->getMemBufferRef();

  if (auto G = jitlink::createLinkGraphFromObject(
          ObjBuffer, getExecutionSession().getSymbolStringPool())) {
    emit(std::move(R), std::move(*G), std::move(O));
  } else {
    R->getExecutionSession().reportError(G.takeError());
    R->failMaterialization();
    return;
  }
}

} // namespace llvm::orc