1 //===---------- AbsoluteSymbols.cpp - Absolute symbols utilities ----------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "llvm/ExecutionEngine/Orc/AbsoluteSymbols.h"
10 #include "llvm/ExecutionEngine/Orc/Core.h"
12 #define DEBUG_TYPE "orc"
16 AbsoluteSymbolsMaterializationUnit::AbsoluteSymbolsMaterializationUnit(
18 : MaterializationUnit(extractFlags(Symbols
)), Symbols(std::move(Symbols
)) {}
20 StringRef
AbsoluteSymbolsMaterializationUnit::getName() const {
21 return "<Absolute Symbols>";
24 void AbsoluteSymbolsMaterializationUnit::materialize(
25 std::unique_ptr
<MaterializationResponsibility
> R
) {
26 // Even though these are just absolute symbols we need to check for failure
27 // to resolve/emit: the tracker for these symbols may have been removed while
28 // the materialization was in flight (e.g. due to a failure in some action
29 // triggered by the queries attached to the resolution/emission of these
31 if (auto Err
= R
->notifyResolved(Symbols
)) {
32 R
->getExecutionSession().reportError(std::move(Err
));
33 R
->failMaterialization();
36 if (auto Err
= R
->notifyEmitted({})) {
37 R
->getExecutionSession().reportError(std::move(Err
));
38 R
->failMaterialization();
43 void AbsoluteSymbolsMaterializationUnit::discard(const JITDylib
&JD
,
44 const SymbolStringPtr
&Name
) {
45 assert(Symbols
.count(Name
) && "Symbol is not part of this MU");
49 MaterializationUnit::Interface
50 AbsoluteSymbolsMaterializationUnit::extractFlags(const SymbolMap
&Symbols
) {
52 for (const auto &[Name
, Def
] : Symbols
)
53 Flags
[Name
] = Def
.getFlags();
54 return MaterializationUnit::Interface(std::move(Flags
), nullptr);
57 } // namespace llvm::orc