Path: blob/main/contrib/llvm-project/llvm/lib/ExecutionEngine/Orc/IRCompileLayer.cpp
35266 views
//===--------------- IRCompileLayer.cpp - IR Compiling Layer --------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"910namespace llvm {11namespace orc {1213IRCompileLayer::IRCompiler::~IRCompiler() = default;1415IRCompileLayer::IRCompileLayer(ExecutionSession &ES, ObjectLayer &BaseLayer,16std::unique_ptr<IRCompiler> Compile)17: IRLayer(ES, ManglingOpts), BaseLayer(BaseLayer),18Compile(std::move(Compile)) {19ManglingOpts = &this->Compile->getManglingOptions();20}2122void IRCompileLayer::setNotifyCompiled(NotifyCompiledFunction NotifyCompiled) {23std::lock_guard<std::mutex> Lock(IRLayerMutex);24this->NotifyCompiled = std::move(NotifyCompiled);25}2627void IRCompileLayer::emit(std::unique_ptr<MaterializationResponsibility> R,28ThreadSafeModule TSM) {29assert(TSM && "Module must not be null");3031if (auto Obj = TSM.withModuleDo(*Compile)) {32{33std::lock_guard<std::mutex> Lock(IRLayerMutex);34if (NotifyCompiled)35NotifyCompiled(*R, std::move(TSM));36else37TSM = ThreadSafeModule();38}39BaseLayer.emit(std::move(R), std::move(*Obj));40} else {41R->failMaterialization();42getExecutionSession().reportError(Obj.takeError());43}44}4546} // End namespace orc.47} // End namespace llvm.484950