Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / llvm / lib / ExecutionEngine / Orc / IRCompileLayer.cpp
blob69aba1fff59ab7f702ce2261660e39450cc05424
1 //===--------------- IRCompileLayer.cpp - IR Compiling 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/IRCompileLayer.h"
11 namespace llvm {
12 namespace orc {
14 IRCompileLayer::IRCompiler::~IRCompiler() = default;
16 IRCompileLayer::IRCompileLayer(ExecutionSession &ES, ObjectLayer &BaseLayer,
17 std::unique_ptr<IRCompiler> Compile)
18 : IRLayer(ES, ManglingOpts), BaseLayer(BaseLayer),
19 Compile(std::move(Compile)) {
20 ManglingOpts = &this->Compile->getManglingOptions();
23 void IRCompileLayer::setNotifyCompiled(NotifyCompiledFunction NotifyCompiled) {
24 std::lock_guard<std::mutex> Lock(IRLayerMutex);
25 this->NotifyCompiled = std::move(NotifyCompiled);
28 void IRCompileLayer::emit(std::unique_ptr<MaterializationResponsibility> R,
29 ThreadSafeModule TSM) {
30 assert(TSM && "Module must not be null");
32 if (auto Obj = TSM.withModuleDo(*Compile)) {
34 std::lock_guard<std::mutex> Lock(IRLayerMutex);
35 if (NotifyCompiled)
36 NotifyCompiled(*R, std::move(TSM));
37 else
38 TSM = ThreadSafeModule();
40 BaseLayer.emit(std::move(R), std::move(*Obj));
41 } else {
42 R->failMaterialization();
43 getExecutionSession().reportError(Obj.takeError());
47 } // End namespace orc.
48 } // End namespace llvm.