Line data Source code
1 : //===-------------- IRTransformLayer.cpp - IR Transform Layer -------------===//
2 : //
3 : // The LLVM Compiler Infrastructure
4 : //
5 : // This file is distributed under the University of Illinois Open Source
6 : // License. See LICENSE.TXT for details.
7 : //
8 : //===----------------------------------------------------------------------===//
9 :
10 : #include "llvm/ExecutionEngine/Orc/IRTransformLayer.h"
11 : #include "llvm/Support/MemoryBuffer.h"
12 :
13 : namespace llvm {
14 : namespace orc {
15 :
16 13 : IRTransformLayer::IRTransformLayer(ExecutionSession &ES,
17 : IRLayer &BaseLayer,
18 13 : TransformFunction Transform)
19 13 : : IRLayer(ES), BaseLayer(BaseLayer), Transform(std::move(Transform)) {}
20 :
21 24 : void IRTransformLayer::emit(MaterializationResponsibility R,
22 : ThreadSafeModule TSM) {
23 : assert(TSM.getModule() && "Module must not be null");
24 :
25 72 : if (auto TransformedTSM = Transform(std::move(TSM), R))
26 48 : BaseLayer.emit(std::move(R), std::move(*TransformedTSM));
27 : else {
28 0 : R.failMaterialization();
29 0 : getExecutionSession().reportError(TransformedTSM.takeError());
30 : }
31 24 : }
32 :
33 : } // End namespace orc.
34 : } // End namespace llvm.
|