
Introduces a new layer interface, LinkGraphLayer, that can be used to add LinkGraphs to an ExecutionSession. This patch moves most of ObjectLinkingLayer's functionality into a new LinkGraphLinkingLayer which should (in the future) be able to be used without linking libObject. ObjectLinkingLayer now inherits from LinkGraphLinkingLayer and just handles conversion of object files to LinkGraphs, which are then handed down to LinkGraphLinkingLayer to be linked.
37 lines
1.2 KiB
C++
37 lines
1.2 KiB
C++
//===------- 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;
|
|
|
|
using BaseObjectLayer = RTTIExtends<ObjectLinkingLayer, ObjectLayer>;
|
|
|
|
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
|