llvm.org GIT mirror llvm / 0ac160f
[ORC] Move ORC Core symbol map and set types into their own header: CoreTypes.h. This will allow other utilities (including a future RuntimeDyld replacement) to use these types without pulling in the major Core types (JITDylib, etc.). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351138 91177308-0d34-0410-b5e6-96231b3b80d8 Lang Hames 1 year, 10 months ago
5 changed file(s) with 411 addition(s) and 347 deletion(s). Raw diff Collapse all Expand all
1414 #define LLVM_EXECUTIONENGINE_ORC_CORE_H
1515
1616 #include "llvm/ADT/BitmaskEnum.h"
17 #include "llvm/ExecutionEngine/JITSymbol.h"
18 #include "llvm/ExecutionEngine/Orc/SymbolStringPool.h"
17 #include "llvm/ExecutionEngine/Orc/CoreTypes.h"
18 #include "llvm/ExecutionEngine/Orc/OrcError.h"
1919 #include "llvm/IR/Module.h"
20 #include "llvm/Support/Debug.h"
2120
2221 #include
23 #include
2422
2523 #define DEBUG_TYPE "orc"
2624
3331 class MaterializationUnit;
3432 class MaterializationResponsibility;
3533 class JITDylib;
36
37 /// VModuleKey provides a unique identifier (allocated and managed by
38 /// ExecutionSessions) for a module added to the JIT.
39 using VModuleKey = uint64_t;
40
41 /// A set of symbol names (represented by SymbolStringPtrs for
42 // efficiency).
43 using SymbolNameSet = DenseSet;
44
45 /// A map from symbol names (as SymbolStringPtrs) to JITSymbols
46 /// (address/flags pairs).
47 using SymbolMap = DenseMap;
48
49 /// A map from symbol names (as SymbolStringPtrs) to JITSymbolFlags.
50 using SymbolFlagsMap = DenseMap;
51
52 /// A base class for materialization failures that allows the failing
53 /// symbols to be obtained for logging.
54 using SymbolDependenceMap = DenseMap;
55
56 /// A list of (JITDylib*, bool) pairs.
57 using JITDylibSearchList = std::vector>;
58
59 /// Render a SymbolStringPtr.
60 raw_ostream &operator<<(raw_ostream &OS, const SymbolStringPtr &Sym);
61
62 /// Render a SymbolNameSet.
63 raw_ostream &operator<<(raw_ostream &OS, const SymbolNameSet &Symbols);
64
65 /// Render a SymbolFlagsMap entry.
66 raw_ostream &operator<<(raw_ostream &OS, const SymbolFlagsMap::value_type &KV);
67
68 /// Render a SymbolMap entry.
69 raw_ostream &operator<<(raw_ostream &OS, const SymbolMap::value_type &KV);
70
71 /// Render a SymbolFlagsMap.
72 raw_ostream &operator<<(raw_ostream &OS, const SymbolFlagsMap &SymbolFlags);
73
74 /// Render a SymbolMap.
75 raw_ostream &operator<<(raw_ostream &OS, const SymbolMap &Symbols);
76
77 /// Render a SymbolDependenceMap entry.
78 raw_ostream &operator<<(raw_ostream &OS,
79 const SymbolDependenceMap::value_type &KV);
80
81 /// Render a SymbolDependendeMap.
82 raw_ostream &operator<<(raw_ostream &OS, const SymbolDependenceMap &Deps);
83
84 /// Render a MaterializationUnit.
85 raw_ostream &operator<<(raw_ostream &OS, const MaterializationUnit &MU);
86
87 /// Render a JITDylibSearchList.
88 raw_ostream &operator<<(raw_ostream &OS, const JITDylibSearchList &JDs);
89
90 /// Callback to notify client that symbols have been resolved.
91 using SymbolsResolvedCallback = std::function)>;
92
93 /// Callback to notify client that symbols are ready for execution.
94 using SymbolsReadyCallback = std::function;
95
96 /// Callback to register the dependencies for a given query.
97 using RegisterDependenciesFunction =
98 std::function;
99
100 /// This can be used as the value for a RegisterDependenciesFunction if there
101 /// are no dependants to register with.
102 extern RegisterDependenciesFunction NoDependenciesToRegister;
103
104 /// Used to notify a JITDylib that the given set of symbols failed to
105 /// materialize.
106 class FailedToMaterialize : public ErrorInfo {
107 public:
108 static char ID;
109
110 FailedToMaterialize(SymbolNameSet Symbols);
111 std::error_code convertToErrorCode() const override;
112 void log(raw_ostream &OS) const override;
113 const SymbolNameSet &getSymbols() const { return Symbols; }
114
115 private:
116 SymbolNameSet Symbols;
117 };
118
119 /// Used to notify clients when symbols can not be found during a lookup.
120 class SymbolsNotFound : public ErrorInfo {
121 public:
122 static char ID;
123
124 SymbolsNotFound(SymbolNameSet Symbols);
125 std::error_code convertToErrorCode() const override;
126 void log(raw_ostream &OS) const override;
127 const SymbolNameSet &getSymbols() const { return Symbols; }
128
129 private:
130 SymbolNameSet Symbols;
131 };
132
133 /// Used to notify clients that a set of symbols could not be removed.
134 class SymbolsCouldNotBeRemoved : public ErrorInfo {
135 public:
136 static char ID;
137
138 SymbolsCouldNotBeRemoved(SymbolNameSet Symbols);
139 std::error_code convertToErrorCode() const override;
140 void log(raw_ostream &OS) const override;
141 const SymbolNameSet &getSymbols() const { return Symbols; }
142
143 private:
144 SymbolNameSet Symbols;
145 };
14634
14735 /// Tracks responsibility for materialization, and mediates interactions between
14836 /// MaterializationUnits and JDs.
0 //===------ CoreTypes.h - ORC Core types (SymbolMap, etc.) ------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Contains core ORC APIs.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #ifndef LLVM_EXECUTIONENGINE_ORC_CORETYPES_H
14 #define LLVM_EXECUTIONENGINE_ORC_CORETYPES_H
15
16 #include "llvm/ADT/DenseMap.h"
17 #include "llvm/ADT/DenseSet.h"
18 #include "llvm/ExecutionEngine/JITSymbol.h"
19 #include "llvm/ExecutionEngine/Orc/SymbolStringPool.h"
20 #include "llvm/Support/Debug.h"
21 #include "llvm/Support/Error.h"
22
23 #include
24 #include
25
26 #define DEBUG_TYPE "orc"
27
28 namespace llvm {
29 namespace orc {
30
31 class JITDylib;
32 class MaterializationUnit;
33
34 /// VModuleKey provides a unique identifier (allocated and managed by
35 /// ExecutionSessions) for a module added to the JIT.
36 using VModuleKey = uint64_t;
37
38 /// A set of symbol names (represented by SymbolStringPtrs for
39 // efficiency).
40 using SymbolNameSet = DenseSet;
41
42 /// A map from symbol names (as SymbolStringPtrs) to JITSymbols
43 /// (address/flags pairs).
44 using SymbolMap = DenseMap;
45
46 /// A map from symbol names (as SymbolStringPtrs) to JITSymbolFlags.
47 using SymbolFlagsMap = DenseMap;
48
49 /// A base class for materialization failures that allows the failing
50 /// symbols to be obtained for logging.
51 using SymbolDependenceMap = DenseMap;
52
53 /// A list of (JITDylib*, bool) pairs.
54 using JITDylibSearchList = std::vector>;
55
56 /// Render a JITSymbolFlags instance.
57 raw_ostream &operator<<(raw_ostream &OS, const JITSymbolFlags &Flags);
58
59 /// Render a SymbolStringPtr.
60 raw_ostream &operator<<(raw_ostream &OS, const SymbolStringPtr &Sym);
61
62 /// Render a SymbolNameSet.
63 raw_ostream &operator<<(raw_ostream &OS, const SymbolNameSet &Symbols);
64
65 /// Render a SymbolFlagsMap entry.
66 raw_ostream &operator<<(raw_ostream &OS, const SymbolFlagsMap::value_type &KV);
67
68 /// Render a SymbolMap entry.
69 raw_ostream &operator<<(raw_ostream &OS, const SymbolMap::value_type &KV);
70
71 /// Render a SymbolFlagsMap.
72 raw_ostream &operator<<(raw_ostream &OS, const SymbolFlagsMap &SymbolFlags);
73
74 /// Render a SymbolMap.
75 raw_ostream &operator<<(raw_ostream &OS, const SymbolMap &Symbols);
76
77 /// Render a SymbolDependenceMap entry.
78 raw_ostream &operator<<(raw_ostream &OS,
79 const SymbolDependenceMap::value_type &KV);
80
81 /// Render a SymbolDependendeMap.
82 raw_ostream &operator<<(raw_ostream &OS, const SymbolDependenceMap &Deps);
83
84 /// Render a MaterializationUnit.
85 raw_ostream &operator<<(raw_ostream &OS, const MaterializationUnit &MU);
86
87 /// Render a JITDylibSearchList.
88 raw_ostream &operator<<(raw_ostream &OS, const JITDylibSearchList &JDs);
89
90 /// Callback to notify client that symbols have been resolved.
91 using SymbolsResolvedCallback = std::function)>;
92
93 /// Callback to notify client that symbols are ready for execution.
94 using SymbolsReadyCallback = std::function;
95
96 /// Callback to register the dependencies for a given query.
97 using RegisterDependenciesFunction =
98 std::function;
99
100 /// This can be used as the value for a RegisterDependenciesFunction if there
101 /// are no dependants to register with.
102 extern RegisterDependenciesFunction NoDependenciesToRegister;
103
104 /// Used to notify a JITDylib that the given set of symbols failed to
105 /// materialize.
106 class FailedToMaterialize : public ErrorInfo {
107 public:
108 static char ID;
109
110 FailedToMaterialize(SymbolNameSet Symbols);
111 std::error_code convertToErrorCode() const override;
112 void log(raw_ostream &OS) const override;
113 const SymbolNameSet &getSymbols() const { return Symbols; }
114
115 private:
116 SymbolNameSet Symbols;
117 };
118
119 /// Used to notify clients when symbols can not be found during a lookup.
120 class SymbolsNotFound : public ErrorInfo {
121 public:
122 static char ID;
123
124 SymbolsNotFound(SymbolNameSet Symbols);
125 std::error_code convertToErrorCode() const override;
126 void log(raw_ostream &OS) const override;
127 const SymbolNameSet &getSymbols() const { return Symbols; }
128
129 private:
130 SymbolNameSet Symbols;
131 };
132
133 /// Used to notify clients that a set of symbols could not be removed.
134 class SymbolsCouldNotBeRemoved : public ErrorInfo {
135 public:
136 static char ID;
137
138 SymbolsCouldNotBeRemoved(SymbolNameSet Symbols);
139 std::error_code convertToErrorCode() const override;
140 void log(raw_ostream &OS) const override;
141 const SymbolNameSet &getSymbols() const { return Symbols; }
142
143 private:
144 SymbolNameSet Symbols;
145 };
146
147 } // End namespace orc
148 } // End namespace llvm
149
150 #undef DEBUG_TYPE // "orc"
151
152 #endif // LLVM_EXECUTIONENGINE_ORC_CORETYPES_H
0 add_llvm_library(LLVMOrcJIT
11 CompileOnDemandLayer.cpp
22 Core.cpp
3 CoreTypes.cpp
34 ExecutionUtils.cpp
45 IndirectionUtils.cpp
56 IRCompileLayer.cpp
77 //===----------------------------------------------------------------------===//
88
99 #include "llvm/ExecutionEngine/Orc/Core.h"
10 #include "llvm/Config/llvm-config.h"
11 #include "llvm/ExecutionEngine/Orc/OrcError.h"
1210 #include "llvm/IR/Mangler.h"
1311 #include "llvm/Support/CommandLine.h"
1412 #include "llvm/Support/Debug.h"
2018
2119 #define DEBUG_TYPE "orc"
2220
23 using namespace llvm;
24
25 namespace {
26
27 #ifndef NDEBUG
28
29 cl::opt PrintHidden("debug-orc-print-hidden", cl::init(false),
30 cl::desc("debug print hidden symbols defined by "
31 "materialization units"),
32 cl::Hidden);
33
34 cl::opt PrintCallable("debug-orc-print-callable", cl::init(false),
35 cl::desc("debug print callable symbols defined by "
36 "materialization units"),
37 cl::Hidden);
38
39 cl::opt PrintData("debug-orc-print-data", cl::init(false),
40 cl::desc("debug print data symbols defined by "
41 "materialization units"),
42 cl::Hidden);
43
44 #endif // NDEBUG
45
46 // SetPrinter predicate that prints every element.
47 template struct PrintAll {
48 bool operator()(const T &E) { return true; }
49 };
50
51 bool anyPrintSymbolOptionSet() {
52 #ifndef NDEBUG
53 return PrintHidden || PrintCallable || PrintData;
54 #else
55 return false;
56 #endif // NDEBUG
57 }
58
59 bool flagsMatchCLOpts(const JITSymbolFlags &Flags) {
60 #ifndef NDEBUG
61 // Bail out early if this is a hidden symbol and we're not printing hiddens.
62 if (!PrintHidden && !Flags.isExported())
63 return false;
64
65 // Return true if this is callable and we're printing callables.
66 if (PrintCallable && Flags.isCallable())
67 return true;
68
69 // Return true if this is data and we're printing data.
70 if (PrintData && !Flags.isCallable())
71 return true;
72
73 // otherwise return false.
74 return false;
75 #else
76 return false;
77 #endif // NDEBUG
78 }
79
80 // Prints a set of items, filtered by an user-supplied predicate.
81 template >
82 class SetPrinter {
83 public:
84 SetPrinter(const Set &S, Pred ShouldPrint = Pred())
85 : S(S), ShouldPrint(std::move(ShouldPrint)) {}
86
87 void printTo(llvm::raw_ostream &OS) const {
88 bool PrintComma = false;
89 OS << "{";
90 for (auto &E : S) {
91 if (ShouldPrint(E)) {
92 if (PrintComma)
93 OS << ',';
94 OS << ' ' << E;
95 PrintComma = true;
96 }
97 }
98 OS << " }";
99 }
100
101 private:
102 const Set &S;
103 mutable Pred ShouldPrint;
104 };
105
106 template
107 SetPrinter printSet(const Set &S, Pred P = Pred()) {
108 return SetPrinter(S, std::move(P));
109 }
110
111 // Render a SetPrinter by delegating to its printTo method.
112 template
113 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
114 const SetPrinter &Printer) {
115 Printer.printTo(OS);
116 return OS;
117 }
118
119 struct PrintSymbolFlagsMapElemsMatchingCLOpts {
120 bool operator()(const orc::SymbolFlagsMap::value_type &KV) {
121 return flagsMatchCLOpts(KV.second);
122 }
123 };
124
125 struct PrintSymbolMapElemsMatchingCLOpts {
126 bool operator()(const orc::SymbolMap::value_type &KV) {
127 return flagsMatchCLOpts(KV.second.getFlags());
128 }
129 };
130
131 } // end anonymous namespace
132
13321 namespace llvm {
13422 namespace orc {
13523
136 SymbolStringPool::PoolMapEntry SymbolStringPtr::Tombstone(0);
137
138 char FailedToMaterialize::ID = 0;
139 char SymbolsNotFound::ID = 0;
140 char SymbolsCouldNotBeRemoved::ID = 0;
24 SymbolStringPool::PoolMapEntry SymbolStringPtr::Tombstone(0);
14125
14226 RegisterDependenciesFunction NoDependenciesToRegister =
14327 RegisterDependenciesFunction();
14428
14529 void MaterializationUnit::anchor() {}
146
147 raw_ostream &operator<<(raw_ostream &OS, const SymbolStringPtr &Sym) {
148 return OS << *Sym;
149 }
150
151 raw_ostream &operator<<(raw_ostream &OS, const SymbolNameSet &Symbols) {
152 return OS << printSet(Symbols, PrintAll());
153 }
154
155 raw_ostream &operator<<(raw_ostream &OS, const JITSymbolFlags &Flags) {
156 if (Flags.isCallable())
157 OS << "[Callable]";
158 else
159 OS << "[Data]";
160 if (Flags.isWeak())
161 OS << "[Weak]";
162 else if (Flags.isCommon())
163 OS << "[Common]";
164
165 if (!Flags.isExported())
166 OS << "[Hidden]";
167
168 return OS;
169 }
170
171 raw_ostream &operator<<(raw_ostream &OS, const JITEvaluatedSymbol &Sym) {
172 return OS << format("0x%016" PRIx64, Sym.getAddress()) << " "
173 << Sym.getFlags();
174 }
175
176 raw_ostream &operator<<(raw_ostream &OS, const SymbolFlagsMap::value_type &KV) {
177 return OS << "(\"" << KV.first << "\", " << KV.second << ")";
178 }
179
180 raw_ostream &operator<<(raw_ostream &OS, const SymbolMap::value_type &KV) {
181 return OS << "(\"" << KV.first << "\": " << KV.second << ")";
182 }
183
184 raw_ostream &operator<<(raw_ostream &OS, const SymbolFlagsMap &SymbolFlags) {
185 return OS << printSet(SymbolFlags, PrintSymbolFlagsMapElemsMatchingCLOpts());
186 }
187
188 raw_ostream &operator<<(raw_ostream &OS, const SymbolMap &Symbols) {
189 return OS << printSet(Symbols, PrintSymbolMapElemsMatchingCLOpts());
190 }
191
192 raw_ostream &operator<<(raw_ostream &OS,
193 const SymbolDependenceMap::value_type &KV) {
194 return OS << "(" << KV.first << ", " << KV.second << ")";
195 }
196
197 raw_ostream &operator<<(raw_ostream &OS, const SymbolDependenceMap &Deps) {
198 return OS << printSet(Deps, PrintAll());
199 }
200
201 raw_ostream &operator<<(raw_ostream &OS, const MaterializationUnit &MU) {
202 OS << "MU@" << &MU << " (\"" << MU.getName() << "\"";
203 if (anyPrintSymbolOptionSet())
204 OS << ", " << MU.getSymbols();
205 return OS << ")";
206 }
207
208 raw_ostream &operator<<(raw_ostream &OS, const JITDylibSearchList &JDs) {
209 OS << "[";
210 if (!JDs.empty()) {
211 assert(JDs.front().first && "JITDylibList entries must not be null");
212 OS << " (\"" << JDs.front().first->getName() << "\", "
213 << (JDs.front().second ? "true" : "false") << ")";
214 for (auto &KV : make_range(std::next(JDs.begin()), JDs.end())) {
215 assert(KV.first && "JITDylibList entries must not be null");
216 OS << ", (\"" << KV.first->getName() << "\", "
217 << (KV.second ? "true" : "false") << ")";
218 }
219 }
220 OS << " ]";
221 return OS;
222 }
223
224 FailedToMaterialize::FailedToMaterialize(SymbolNameSet Symbols)
225 : Symbols(std::move(Symbols)) {
226 assert(!this->Symbols.empty() && "Can not fail to resolve an empty set");
227 }
228
229 std::error_code FailedToMaterialize::convertToErrorCode() const {
230 return orcError(OrcErrorCode::UnknownORCError);
231 }
232
233 void FailedToMaterialize::log(raw_ostream &OS) const {
234 OS << "Failed to materialize symbols: " << Symbols;
235 }
236
237 SymbolsNotFound::SymbolsNotFound(SymbolNameSet Symbols)
238 : Symbols(std::move(Symbols)) {
239 assert(!this->Symbols.empty() && "Can not fail to resolve an empty set");
240 }
241
242 std::error_code SymbolsNotFound::convertToErrorCode() const {
243 return orcError(OrcErrorCode::UnknownORCError);
244 }
245
246 void SymbolsNotFound::log(raw_ostream &OS) const {
247 OS << "Symbols not found: " << Symbols;
248 }
249
250 SymbolsCouldNotBeRemoved::SymbolsCouldNotBeRemoved(SymbolNameSet Symbols)
251 : Symbols(std::move(Symbols)) {
252 assert(!this->Symbols.empty() && "Can not fail to resolve an empty set");
253 }
254
255 std::error_code SymbolsCouldNotBeRemoved::convertToErrorCode() const {
256 return orcError(OrcErrorCode::UnknownORCError);
257 }
258
259 void SymbolsCouldNotBeRemoved::log(raw_ostream &OS) const {
260 OS << "Symbols could not be removed: " << Symbols;
261 }
26230
26331 AsynchronousSymbolQuery::AsynchronousSymbolQuery(
26432 const SymbolNameSet &Symbols, SymbolsResolvedCallback NotifySymbolsResolved,
0 //===--- Core.cpp - Core ORC APIs (MaterializationUnit, JITDylib, etc.) ---===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "llvm/ExecutionEngine/Orc/CoreTypes.h"
10 #include "llvm/Config/llvm-config.h"
11 #include "llvm/ExecutionEngine/Orc/Core.h"
12 #include "llvm/ExecutionEngine/Orc/OrcError.h"
13 #include "llvm/Support/CommandLine.h"
14 #include "llvm/Support/Debug.h"
15 #include "llvm/Support/Format.h"
16
17 #define DEBUG_TYPE "orc"
18
19 using namespace llvm;
20
21 namespace {
22
23 #ifndef NDEBUG
24
25 cl::opt PrintHidden("debug-orc-print-hidden", cl::init(false),
26 cl::desc("debug print hidden symbols defined by "
27 "materialization units"),
28 cl::Hidden);
29
30 cl::opt PrintCallable("debug-orc-print-callable", cl::init(false),
31 cl::desc("debug print callable symbols defined by "
32 "materialization units"),
33 cl::Hidden);
34
35 cl::opt PrintData("debug-orc-print-data", cl::init(false),
36 cl::desc("debug print data symbols defined by "
37 "materialization units"),
38 cl::Hidden);
39
40 #endif // NDEBUG
41
42 // SetPrinter predicate that prints every element.
43 template struct PrintAll {
44 bool operator()(const T &E) { return true; }
45 };
46
47 bool anyPrintSymbolOptionSet() {
48 #ifndef NDEBUG
49 return PrintHidden || PrintCallable || PrintData;
50 #else
51 return false;
52 #endif // NDEBUG
53 }
54
55 bool flagsMatchCLOpts(const JITSymbolFlags &Flags) {
56 #ifndef NDEBUG
57 // Bail out early if this is a hidden symbol and we're not printing hiddens.
58 if (!PrintHidden && !Flags.isExported())
59 return false;
60
61 // Return true if this is callable and we're printing callables.
62 if (PrintCallable && Flags.isCallable())
63 return true;
64
65 // Return true if this is data and we're printing data.
66 if (PrintData && !Flags.isCallable())
67 return true;
68
69 // otherwise return false.
70 return false;
71 #else
72 return false;
73 #endif // NDEBUG
74 }
75
76 // Prints a set of items, filtered by an user-supplied predicate.
77 template >
78 class SetPrinter {
79 public:
80 SetPrinter(const Set &S, Pred ShouldPrint = Pred())
81 : S(S), ShouldPrint(std::move(ShouldPrint)) {}
82
83 void printTo(llvm::raw_ostream &OS) const {
84 bool PrintComma = false;
85 OS << "{";
86 for (auto &E : S) {
87 if (ShouldPrint(E)) {
88 if (PrintComma)
89 OS << ',';
90 OS << ' ' << E;
91 PrintComma = true;
92 }
93 }
94 OS << " }";
95 }
96
97 private:
98 const Set &S;
99 mutable Pred ShouldPrint;
100 };
101
102 template
103 SetPrinter printSet(const Set &S, Pred P = Pred()) {
104 return SetPrinter(S, std::move(P));
105 }
106
107 // Render a SetPrinter by delegating to its printTo method.
108 template
109 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
110 const SetPrinter &Printer) {
111 Printer.printTo(OS);
112 return OS;
113 }
114
115 struct PrintSymbolFlagsMapElemsMatchingCLOpts {
116 bool operator()(const orc::SymbolFlagsMap::value_type &KV) {
117 return flagsMatchCLOpts(KV.second);
118 }
119 };
120
121 struct PrintSymbolMapElemsMatchingCLOpts {
122 bool operator()(const orc::SymbolMap::value_type &KV) {
123 return flagsMatchCLOpts(KV.second.getFlags());
124 }
125 };
126
127 } // end anonymous namespace
128
129 namespace llvm {
130 namespace orc {
131
132 char FailedToMaterialize::ID = 0;
133 char SymbolsNotFound::ID = 0;
134 char SymbolsCouldNotBeRemoved::ID = 0;
135
136 raw_ostream &operator<<(raw_ostream &OS, const SymbolStringPtr &Sym) {
137 return OS << *Sym;
138 }
139
140 raw_ostream &operator<<(raw_ostream &OS, const SymbolNameSet &Symbols) {
141 return OS << printSet(Symbols, PrintAll());
142 }
143
144 raw_ostream &operator<<(raw_ostream &OS, const JITSymbolFlags &Flags) {
145 if (Flags.isCallable())
146 OS << "[Callable]";
147 else
148 OS << "[Data]";
149 if (Flags.isWeak())
150 OS << "[Weak]";
151 else if (Flags.isCommon())
152 OS << "[Common]";
153
154 if (!Flags.isExported())
155 OS << "[Hidden]";
156
157 return OS;
158 }
159
160 raw_ostream &operator<<(raw_ostream &OS, const JITEvaluatedSymbol &Sym) {
161 return OS << format("0x%016" PRIx64, Sym.getAddress()) << " "
162 << Sym.getFlags();
163 }
164
165 raw_ostream &operator<<(raw_ostream &OS, const SymbolFlagsMap::value_type &KV) {
166 return OS << "(\"" << KV.first << "\", " << KV.second << ")";
167 }
168
169 raw_ostream &operator<<(raw_ostream &OS, const SymbolMap::value_type &KV) {
170 return OS << "(\"" << KV.first << "\": " << KV.second << ")";
171 }
172
173 raw_ostream &operator<<(raw_ostream &OS, const SymbolFlagsMap &SymbolFlags) {
174 return OS << printSet(SymbolFlags, PrintSymbolFlagsMapElemsMatchingCLOpts());
175 }
176
177 raw_ostream &operator<<(raw_ostream &OS, const SymbolMap &Symbols) {
178 return OS << printSet(Symbols, PrintSymbolMapElemsMatchingCLOpts());
179 }
180
181 raw_ostream &operator<<(raw_ostream &OS,
182 const SymbolDependenceMap::value_type &KV) {
183 return OS << "(" << KV.first << ", " << KV.second << ")";
184 }
185
186 raw_ostream &operator<<(raw_ostream &OS, const SymbolDependenceMap &Deps) {
187 return OS << printSet(Deps, PrintAll());
188 }
189
190 raw_ostream &operator<<(raw_ostream &OS, const MaterializationUnit &MU) {
191 OS << "MU@" << &MU << " (\"" << MU.getName() << "\"";
192 if (anyPrintSymbolOptionSet())
193 OS << ", " << MU.getSymbols();
194 return OS << ")";
195 }
196
197 raw_ostream &operator<<(raw_ostream &OS, const JITDylibSearchList &JDs) {
198 OS << "[";
199 if (!JDs.empty()) {
200 assert(JDs.front().first && "JITDylibList entries must not be null");
201 OS << " (\"" << JDs.front().first->getName() << "\", "
202 << (JDs.front().second ? "true" : "false") << ")";
203 for (auto &KV : make_range(std::next(JDs.begin()), JDs.end())) {
204 assert(KV.first && "JITDylibList entries must not be null");
205 OS << ", (\"" << KV.first->getName() << "\", "
206 << (KV.second ? "true" : "false") << ")";
207 }
208 }
209 OS << " ]";
210 return OS;
211 }
212
213 FailedToMaterialize::FailedToMaterialize(SymbolNameSet Symbols)
214 : Symbols(std::move(Symbols)) {
215 assert(!this->Symbols.empty() && "Can not fail to resolve an empty set");
216 }
217
218 std::error_code FailedToMaterialize::convertToErrorCode() const {
219 return orcError(OrcErrorCode::UnknownORCError);
220 }
221
222 void FailedToMaterialize::log(raw_ostream &OS) const {
223 OS << "Failed to materialize symbols: " << Symbols;
224 }
225
226 SymbolsNotFound::SymbolsNotFound(SymbolNameSet Symbols)
227 : Symbols(std::move(Symbols)) {
228 assert(!this->Symbols.empty() && "Can not fail to resolve an empty set");
229 }
230
231 std::error_code SymbolsNotFound::convertToErrorCode() const {
232 return orcError(OrcErrorCode::UnknownORCError);
233 }
234
235 void SymbolsNotFound::log(raw_ostream &OS) const {
236 OS << "Symbols not found: " << Symbols;
237 }
238
239 SymbolsCouldNotBeRemoved::SymbolsCouldNotBeRemoved(SymbolNameSet Symbols)
240 : Symbols(std::move(Symbols)) {
241 assert(!this->Symbols.empty() && "Can not fail to resolve an empty set");
242 }
243
244 std::error_code SymbolsCouldNotBeRemoved::convertToErrorCode() const {
245 return orcError(OrcErrorCode::UnknownORCError);
246 }
247
248 void SymbolsCouldNotBeRemoved::log(raw_ostream &OS) const {
249 OS << "Symbols could not be removed: " << Symbols;
250 }
251
252 } // End namespace orc.
253 } // End namespace llvm.