Path: blob/main/contrib/llvm-project/llvm/lib/ExecutionEngine/Orc/AbsoluteSymbols.cpp
213799 views
//===---------- AbsoluteSymbols.cpp - Absolute symbols utilities ----------===//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/AbsoluteSymbols.h"9#include "llvm/ExecutionEngine/Orc/Core.h"1011#define DEBUG_TYPE "orc"1213namespace llvm::orc {1415AbsoluteSymbolsMaterializationUnit::AbsoluteSymbolsMaterializationUnit(16SymbolMap Symbols)17: MaterializationUnit(extractFlags(Symbols)), Symbols(std::move(Symbols)) {}1819StringRef AbsoluteSymbolsMaterializationUnit::getName() const {20return "<Absolute Symbols>";21}2223void AbsoluteSymbolsMaterializationUnit::materialize(24std::unique_ptr<MaterializationResponsibility> R) {25// Even though these are just absolute symbols we need to check for failure26// to resolve/emit: the tracker for these symbols may have been removed while27// the materialization was in flight (e.g. due to a failure in some action28// triggered by the queries attached to the resolution/emission of these29// symbols).30if (auto Err = R->notifyResolved(Symbols)) {31R->getExecutionSession().reportError(std::move(Err));32R->failMaterialization();33return;34}35if (auto Err = R->notifyEmitted({})) {36R->getExecutionSession().reportError(std::move(Err));37R->failMaterialization();38return;39}40}4142void AbsoluteSymbolsMaterializationUnit::discard(const JITDylib &JD,43const SymbolStringPtr &Name) {44assert(Symbols.count(Name) && "Symbol is not part of this MU");45Symbols.erase(Name);46}4748MaterializationUnit::Interface49AbsoluteSymbolsMaterializationUnit::extractFlags(const SymbolMap &Symbols) {50SymbolFlagsMap Flags;51for (const auto &[Name, Def] : Symbols)52Flags[Name] = Def.getFlags();53return MaterializationUnit::Interface(std::move(Flags), nullptr);54}5556} // namespace llvm::orc575859