58 lines · cpp
1//===---------- AbsoluteSymbols.cpp - Absolute symbols utilities ----------===//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-exception6//7//===----------------------------------------------------------------------===//8 9#include "llvm/ExecutionEngine/Orc/AbsoluteSymbols.h"10#include "llvm/ExecutionEngine/Orc/Core.h"11 12#define DEBUG_TYPE "orc"13 14namespace llvm::orc {15 16AbsoluteSymbolsMaterializationUnit::AbsoluteSymbolsMaterializationUnit(17 SymbolMap Symbols)18 : MaterializationUnit(extractFlags(Symbols)), Symbols(std::move(Symbols)) {}19 20StringRef AbsoluteSymbolsMaterializationUnit::getName() const {21 return "<Absolute Symbols>";22}23 24void AbsoluteSymbolsMaterializationUnit::materialize(25 std::unique_ptr<MaterializationResponsibility> R) {26 // Even though these are just absolute symbols we need to check for failure27 // to resolve/emit: the tracker for these symbols may have been removed while28 // the materialization was in flight (e.g. due to a failure in some action29 // triggered by the queries attached to the resolution/emission of these30 // symbols).31 if (auto Err = R->notifyResolved(Symbols)) {32 R->getExecutionSession().reportError(std::move(Err));33 R->failMaterialization();34 return;35 }36 if (auto Err = R->notifyEmitted({})) {37 R->getExecutionSession().reportError(std::move(Err));38 R->failMaterialization();39 return;40 }41}42 43void AbsoluteSymbolsMaterializationUnit::discard(const JITDylib &JD,44 const SymbolStringPtr &Name) {45 assert(Symbols.count(Name) && "Symbol is not part of this MU");46 Symbols.erase(Name);47}48 49MaterializationUnit::Interface50AbsoluteSymbolsMaterializationUnit::extractFlags(const SymbolMap &Symbols) {51 SymbolFlagsMap Flags;52 for (const auto &[Name, Def] : Symbols)53 Flags[Name] = Def.getFlags();54 return MaterializationUnit::Interface(std::move(Flags), nullptr);55}56 57} // namespace llvm::orc58