LLVM 20.0.0git
AbsoluteSymbols.cpp
Go to the documentation of this file.
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-exception
6//
7//===----------------------------------------------------------------------===//
8
11
12#define DEBUG_TYPE "orc"
13
14namespace llvm::orc {
15
17 SymbolMap Symbols)
18 : MaterializationUnit(extractFlags(Symbols)), Symbols(std::move(Symbols)) {}
19
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 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
30 // 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::Interface
50AbsoluteSymbolsMaterializationUnit::extractFlags(const SymbolMap &Symbols) {
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::orc
std::string Name
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool erase(const KeyT &Val)
Definition: DenseMap.h:321
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
Definition: DenseMap.h:152
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
StringRef getName() const override
Return the name of this materialization unit.
A MaterializationUnit represents a set of symbol definitions that can be materialized as a group,...
DenseMap< SymbolStringPtr, ExecutorSymbolDef > SymbolMap
A map from symbol names (as SymbolStringPtrs) to JITSymbols (address/flags pairs).
DenseMap< SymbolStringPtr, JITSymbolFlags > SymbolFlagsMap
A map from symbol names (as SymbolStringPtrs) to JITSymbolFlags.
NodeAddr< DefNode * > Def
Definition: RDFGraph.h:384
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1873
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858