1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 04:32:44 +01:00
llvm-mirror/lib/ExecutionEngine/Orc/IRTransformLayer.cpp
Lang Hames 4ec13fba1c Re-apply "[ORC] Make MaterializationResponsibility immovable..." with fixes.
Re-applies c74900ca672 with fixes for the ThinLtoJIT example.
2020-09-11 14:09:05 -07:00

34 lines
1.2 KiB
C++

//===-------------- IRTransformLayer.cpp - IR Transform Layer -------------===//
//
// 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/IRTransformLayer.h"
#include "llvm/Support/MemoryBuffer.h"
namespace llvm {
namespace orc {
IRTransformLayer::IRTransformLayer(ExecutionSession &ES, IRLayer &BaseLayer,
TransformFunction Transform)
: IRLayer(ES, BaseLayer.getManglingOptions()), BaseLayer(BaseLayer),
Transform(std::move(Transform)) {}
void IRTransformLayer::emit(std::unique_ptr<MaterializationResponsibility> R,
ThreadSafeModule TSM) {
assert(TSM && "Module must not be null");
if (auto TransformedTSM = Transform(std::move(TSM), *R))
BaseLayer.emit(std::move(R), std::move(*TransformedTSM));
else {
R->failMaterialization();
getExecutionSession().reportError(TransformedTSM.takeError());
}
}
} // End namespace orc.
} // End namespace llvm.