20#define DEBUG_TYPE "orc"
29 cl::desc(
"debug print hidden symbols defined by "
30 "materialization units"),
34 cl::desc(
"debug print callable symbols defined by "
35 "materialization units"),
39 cl::desc(
"debug print data symbols defined by "
40 "materialization units"),
46template <
typename T>
struct PrintAll {
47 bool operator()(
const T &E) {
return true; }
50bool anyPrintSymbolOptionSet() {
52 return PrintHidden || PrintCallable || PrintData;
61 if (!PrintHidden && !Flags.isExported())
65 if (PrintCallable && Flags.isCallable())
69 if (PrintData && !Flags.isCallable())
80template <
typename Sequence,
81 typename Pred = PrintAll<typename Sequence::value_type>>
82class SequencePrinter {
84 SequencePrinter(
const Sequence &S,
char OpenSeq,
char CloseSeq,
85 Pred ShouldPrint = Pred())
86 : S(S), OpenSeq(OpenSeq), CloseSeq(CloseSeq),
87 ShouldPrint(std::move(ShouldPrint)) {}
90 bool PrintComma =
false;
100 OS <<
' ' << CloseSeq;
107 mutable Pred ShouldPrint;
110template <
typename Sequence,
typename Pred>
111SequencePrinter<Sequence, Pred> printSequence(
const Sequence &S,
char OpenSeq,
112 char CloseSeq, Pred
P = Pred()) {
113 return SequencePrinter<Sequence, Pred>(S, OpenSeq, CloseSeq, std::move(
P));
117template <
typename Sequence,
typename Pred>
119 const SequencePrinter<Sequence, Pred> &
Printer) {
124struct PrintSymbolFlagsMapElemsMatchingCLOpts {
126 return flagsMatchCLOpts(KV.second);
130struct PrintSymbolMapElemsMatchingCLOpts {
132 return flagsMatchCLOpts(KV.second.getFlags());
150 return OS << printSequence(Symbols,
'{',
'}', PrintAll<SymbolStringPtr>());
154 return OS << printSequence(Symbols, '[', ']', PrintAll<SymbolStringPtr>());
158 return OS << printSequence(Symbols, '[', ']', PrintAll<SymbolStringPtr>());
162 if (Flags.hasError())
164 if (Flags.isCallable())
170 else if (Flags.isCommon())
173 if (!Flags.isExported())
180 return OS <<
Sym.getAddress() <<
" " <<
Sym.getFlags();
184 return OS <<
"(\"" << KV.first <<
"\", " << KV.second <<
")";
188 return OS <<
"(\"" << KV.first <<
"\": " << KV.second <<
")";
192 return OS << printSequence(SymbolFlags,
'{',
'}',
193 PrintSymbolFlagsMapElemsMatchingCLOpts());
197 return OS << printSequence(Symbols,
'{',
'}',
198 PrintSymbolMapElemsMatchingCLOpts());
203 return OS <<
"(" << KV.first->getName() <<
", " << KV.second <<
")";
207 return OS << printSequence(Deps,
'{',
'}',
208 PrintAll<SymbolDependenceMap::value_type>());
212 OS <<
"MU@" << &MU <<
" (\"" << MU.
getName() <<
"\"";
213 if (anyPrintSymbolOptionSet())
221 return OS <<
"Static";
223 return OS <<
"DLSym";
230 switch (JDLookupFlags) {
232 return OS <<
"MatchExportedSymbolsOnly";
234 return OS <<
"MatchAllSymbols";
240 switch (LookupFlags) {
242 return OS <<
"RequiredSymbol";
244 return OS <<
"WeaklyReferencedSymbol";
251 return OS <<
"(" << KV.first <<
", " << KV.second <<
")";
255 return OS << printSequence(LookupSet,
'{',
'}',
256 PrintAll<SymbolLookupSet::value_type>());
262 if (!SearchOrder.empty()) {
263 assert(SearchOrder.front().first &&
264 "JITDylibList entries must not be null");
265 OS <<
" (\"" << SearchOrder.front().first->getName() <<
"\", "
266 << SearchOrder.begin()->second <<
")";
268 assert(KV.first &&
"JITDylibList entries must not be null");
269 OS <<
", (\"" << KV.first->getName() <<
"\", " << KV.second <<
")";
278 for (
auto &KV : Aliases)
279 OS <<
" " << *KV.first <<
": " << KV.second.Aliasee <<
" "
280 << KV.second.AliasFlags;
288 return OS <<
"Invalid";
290 return OS <<
"Never-Searched";
292 return OS <<
"Materializing";
294 return OS <<
"Resolved";
296 return OS <<
"Emitted";
298 return OS <<
"Ready";
304 std::lock_guard<std::mutex> Lock(SSP.PoolMutex);
306 for (
auto &KV : SSP.Pool)
309 for (
auto &[K, V] : Vec)
310 OS << K <<
": " << V <<
"\n";
316 IdentifierOverride(
std::
move(IdentifierOverride)) {
319 while (!this->DumpDir.empty() &&
321 this->DumpDir.pop_back();
328 std::string DumpPathStem;
330 << DumpDir << (DumpDir.empty() ?
"" :
"/") << getBufferIdentifier(*Obj);
332 std::string DumpPath = DumpPathStem +
".o";
340 <<
" -- " << (
const void *)(Obj->getBufferEnd() - 1) <<
" ] to "
348 DumpStream.
write(Obj->getBufferStart(), Obj->getBufferSize());
350 return std::move(Obj);
354 if (!IdentifierOverride.empty())
355 return IdentifierOverride;
356 StringRef Identifier =
B.getBufferIdentifier();
357 Identifier.consume_back(
".o");
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
dxil pretty DXIL Metadata Pretty Printer
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Tagged union holding either a T or a Error.
Flags for symbols in the JIT.
This interface provides simple read-only access to a block of memory, and provides simple methods for...
reference emplace_back(ArgTypes &&... Args)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Expected< std::unique_ptr< MemoryBuffer > > operator()(std::unique_ptr< MemoryBuffer > Obj)
Dumps the given buffer to disk.
DumpObjects(std::string DumpDir="", std::string IdentifierOverride="")
Construct a DumpObjects transform that will dump objects to disk.
Represents a defining location for a JIT symbol.
A MaterializationUnit represents a set of symbol definitions that can be materialized as a group,...
virtual StringRef getName() const =0
Return the name of this materialization unit.
const SymbolFlagsMap & getSymbols() const
Return the set of symbols that this source provides.
Non-owning SymbolStringPool entry pointer.
A set of symbols to look up, each associated with a SymbolLookupFlags value.
std::pair< SymbolStringPtr, SymbolLookupFlags > value_type
String pool for symbol names used by the JIT.
Pointer to a pooled string representing a symbol name.
A raw_ostream that writes to a file descriptor.
This class implements an extremely fast bulk output stream that can only output to a stream.
raw_ostream & write(unsigned char C)
const char * getBufferStart() const
Return the beginning of the current stream buffer, or 0 if the stream is unbuffered.
A raw_ostream that writes to an std::string.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
initializer< Ty > init(const Ty &Val)
std::vector< std::pair< JITDylib *, JITDylibLookupFlags > > JITDylibSearchOrder
A list of (JITDylib*, JITDylibLookupFlags) pairs to be used as a search order during symbol lookup.
SymbolLookupFlags
Lookup flags that apply to each symbol in a lookup.
JITDylibLookupFlags
Lookup flags that apply to each dylib in the search order for a lookup.
@ MatchExportedSymbolsOnly
LookupKind
Describes the kind of lookup being performed.
std::vector< SymbolStringPtr > SymbolNameVector
A vector of symbol names.
SymbolState
Represents the state that a symbol has reached during materialization.
@ Materializing
Added to the symbol table, never queried.
@ NeverSearched
No symbol should be in this state.
@ Ready
Emitted to memory, but waiting on transitive dependencies.
@ Emitted
Assigned address, still materializing.
@ Resolved
Queried, materialization begun.
raw_ostream & operator<<(raw_ostream &OS, const SymbolStringPtr &Sym)
Render a SymbolStringPtr.
bool exists(const basic_file_status &status)
Does file exist?
bool is_separator(char value, Style style=Style::native)
Check whether the given char is a path separator on the host OS.
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
void sort(IteratorTy Start, IteratorTy End)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
Implement std::hash so that hash_code can be used in STL containers.
Function object to check whether the first component of a container supported by std::get (like std::...