AMDGPU: Mark test as XFAIL in expensive_checks builds
[llvm-project.git] / llvm / lib / ExecutionEngine / Orc / ObjectTransformLayer.cpp
blob207a31ec19407983e32d59a8bdc6c4d6be40fcae
1 //===---------- ObjectTransformLayer.cpp - Object Transform Layer ---------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 #include "llvm/ExecutionEngine/Orc/ObjectTransformLayer.h"
10 #include "llvm/Support/MemoryBuffer.h"
12 namespace llvm {
13 namespace orc {
15 char ObjectTransformLayer::ID;
17 using BaseT = RTTIExtends<ObjectTransformLayer, ObjectLayer>;
19 ObjectTransformLayer::ObjectTransformLayer(ExecutionSession &ES,
20 ObjectLayer &BaseLayer,
21 TransformFunction Transform)
22 : BaseT(ES), BaseLayer(BaseLayer), Transform(std::move(Transform)) {}
24 void ObjectTransformLayer::emit(
25 std::unique_ptr<MaterializationResponsibility> R,
26 std::unique_ptr<MemoryBuffer> O) {
27 assert(O && "Module must not be null");
29 // If there is a transform set then apply it.
30 if (Transform) {
31 if (auto TransformedObj = Transform(std::move(O)))
32 O = std::move(*TransformedObj);
33 else {
34 R->failMaterialization();
35 getExecutionSession().reportError(TransformedObj.takeError());
36 return;
40 BaseLayer.emit(std::move(R), std::move(O));
43 } // End namespace orc.
44 } // End namespace llvm.