19#define DEBUG_TYPE "orc"
28 cl::desc(
"debug print hidden symbols defined by "
29 "materialization units"),
33 cl::desc(
"debug print callable symbols defined by "
34 "materialization units"),
38 cl::desc(
"debug print data symbols defined by "
39 "materialization units"),
45template <
typename T>
struct PrintAll {
46 bool operator()(
const T &E) {
return true; }
49bool anyPrintSymbolOptionSet() {
51 return PrintHidden || PrintCallable || PrintData;
60 if (!PrintHidden && !Flags.isExported())
64 if (PrintCallable && Flags.isCallable())
68 if (PrintData && !Flags.isCallable())
79template <
typename Sequence,
80 typename Pred = PrintAll<typename Sequence::value_type>>
81class SequencePrinter {
83 SequencePrinter(
const Sequence &S,
char OpenSeq,
char CloseSeq,
84 Pred ShouldPrint = Pred())
85 : S(S), OpenSeq(OpenSeq), CloseSeq(CloseSeq),
86 ShouldPrint(std::move(ShouldPrint)) {}
89 bool PrintComma =
false;
99 OS <<
' ' << CloseSeq;
106 mutable Pred ShouldPrint;
109template <
typename Sequence,
typename Pred>
110SequencePrinter<Sequence, Pred> printSequence(
const Sequence &S,
char OpenSeq,
111 char CloseSeq, Pred
P = Pred()) {
112 return SequencePrinter<Sequence, Pred>(S, OpenSeq, CloseSeq, std::move(
P));
116template <
typename Sequence,
typename Pred>
118 const SequencePrinter<Sequence, Pred> &
Printer) {
123struct PrintSymbolFlagsMapElemsMatchingCLOpts {
125 return flagsMatchCLOpts(KV.second);
129struct PrintSymbolMapElemsMatchingCLOpts {
131 return flagsMatchCLOpts(KV.second.getFlags());
141 return OS << printSequence(Symbols,
'{',
'}', PrintAll<SymbolStringPtr>());
145 return OS << printSequence(Symbols, '[', ']', PrintAll<SymbolStringPtr>());
149 return OS << printSequence(Symbols, '[', ']', PrintAll<SymbolStringPtr>());
153 if (Flags.hasError())
155 if (Flags.isCallable())
161 else if (Flags.isCommon())
164 if (!Flags.isExported())
171 return OS <<
Sym.getAddress() <<
" " <<
Sym.getFlags();
175 return OS <<
"(\"" << KV.first <<
"\", " << KV.second <<
")";
179 return OS <<
"(\"" << KV.first <<
"\": " << KV.second <<
")";
183 return OS << printSequence(SymbolFlags,
'{',
'}',
184 PrintSymbolFlagsMapElemsMatchingCLOpts());
188 return OS << printSequence(Symbols,
'{',
'}',
189 PrintSymbolMapElemsMatchingCLOpts());
194 return OS <<
"(" << KV.first->getName() <<
", " << KV.second <<
")";
198 return OS << printSequence(Deps,
'{',
'}',
199 PrintAll<SymbolDependenceMap::value_type>());
203 OS <<
"MU@" << &MU <<
" (\"" << MU.
getName() <<
"\"";
204 if (anyPrintSymbolOptionSet())
212 return OS <<
"Static";
214 return OS <<
"DLSym";
221 switch (JDLookupFlags) {
223 return OS <<
"MatchExportedSymbolsOnly";
225 return OS <<
"MatchAllSymbols";
231 switch (LookupFlags) {
233 return OS <<
"RequiredSymbol";
235 return OS <<
"WeaklyReferencedSymbol";
242 return OS <<
"(" << KV.first <<
", " << KV.second <<
")";
246 return OS << printSequence(LookupSet,
'{',
'}',
247 PrintAll<SymbolLookupSet::value_type>());
253 if (!SearchOrder.empty()) {
254 assert(SearchOrder.front().first &&
255 "JITDylibList entries must not be null");
256 OS <<
" (\"" << SearchOrder.front().first->getName() <<
"\", "
257 << SearchOrder.begin()->second <<
")";
259 assert(KV.first &&
"JITDylibList entries must not be null");
260 OS <<
", (\"" << KV.first->getName() <<
"\", " << KV.second <<
")";
269 for (
auto &KV : Aliases)
270 OS <<
" " << *KV.first <<
": " << KV.second.Aliasee <<
" "
271 << KV.second.AliasFlags;
279 return OS <<
"Invalid";
281 return OS <<
"Never-Searched";
283 return OS <<
"Materializing";
285 return OS <<
"Resolved";
287 return OS <<
"Emitted";
289 return OS <<
"Ready";
295 std::lock_guard<std::mutex> Lock(SSP.PoolMutex);
297 for (
auto &KV : SSP.Pool)
300 for (
auto &[K, V] : Vec)
301 OS << K <<
": " << V <<
"\n";
307 IdentifierOverride(
std::
move(IdentifierOverride)) {
310 while (!this->DumpDir.empty() &&
312 this->DumpDir.pop_back();
319 std::string DumpPathStem;
321 << DumpDir << (DumpDir.empty() ?
"" :
"/") << getBufferIdentifier(*Obj);
323 std::string DumpPath = DumpPathStem +
".o";
331 <<
" -- " << (
const void *)(Obj->getBufferEnd() - 1) <<
" ] to "
339 DumpStream.
write(Obj->getBufferStart(), Obj->getBufferSize());
341 return std::move(Obj);
345 if (!IdentifierOverride.empty())
346 return IdentifierOverride;
347 StringRef Identifier =
B.getBufferIdentifier();
348 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.
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.
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.
raw_ostream & operator<<(raw_ostream &OS, const SymbolNameSet &Symbols)
Render a SymbolNameSet.
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.
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::...