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());
146 return OS << printSequence(Symbols,
'{',
'}', PrintAll<SymbolStringPtr>());
150 return OS << printSequence(Symbols, '[', ']', PrintAll<SymbolStringPtr>());
154 return OS << printSequence(Symbols, '[', ']', PrintAll<SymbolStringPtr>());
158 if (
Flags.hasError())
160 if (
Flags.isCallable())
166 else if (
Flags.isCommon())
169 if (!
Flags.isExported())
181 return OS <<
"(\"" << KV.first <<
"\", " << KV.second <<
")";
185 return OS <<
"(\"" << KV.first <<
"\": " << KV.second <<
")";
189 return OS << printSequence(SymbolFlags,
'{',
'}',
190 PrintSymbolFlagsMapElemsMatchingCLOpts());
194 return OS << printSequence(Symbols,
'{',
'}',
195 PrintSymbolMapElemsMatchingCLOpts());
200 return OS <<
"(" << KV.first->getName() <<
", " << KV.second <<
")";
204 return OS << printSequence(Deps,
'{',
'}',
205 PrintAll<SymbolDependenceMap::value_type>());
209 OS <<
"MU@" << &MU <<
" (\"" << MU.
getName() <<
"\"";
210 if (anyPrintSymbolOptionSet())
218 return OS <<
"Static";
220 return OS <<
"DLSym";
227 switch (JDLookupFlags) {
229 return OS <<
"MatchExportedSymbolsOnly";
231 return OS <<
"MatchAllSymbols";
237 switch (LookupFlags) {
239 return OS <<
"RequiredSymbol";
241 return OS <<
"WeaklyReferencedSymbol";
248 return OS <<
"(" << KV.first <<
", " << KV.second <<
")";
252 return OS << printSequence(LookupSet,
'{',
'}',
253 PrintAll<SymbolLookupSet::value_type>());
259 if (!SearchOrder.empty()) {
260 assert(SearchOrder.front().first &&
261 "JITDylibList entries must not be null");
262 OS <<
" (\"" << SearchOrder.front().first->getName() <<
"\", "
263 << SearchOrder.begin()->second <<
")";
265 assert(KV.first &&
"JITDylibList entries must not be null");
266 OS <<
", (\"" << KV.first->getName() <<
"\", " << KV.second <<
")";
275 for (
auto &KV : Aliases)
276 OS <<
" " << *KV.first <<
": " << KV.second.Aliasee <<
" "
277 << KV.second.AliasFlags;
285 return OS <<
"Invalid";
287 return OS <<
"Never-Searched";
289 return OS <<
"Materializing";
291 return OS <<
"Resolved";
293 return OS <<
"Emitted";
295 return OS <<
"Ready";
301 std::lock_guard<std::mutex> Lock(SSP.PoolMutex);
302 for (
auto &KV : SSP.Pool)
303 OS << KV.first() <<
": " << KV.second <<
"\n";
309 IdentifierOverride(
std::
move(IdentifierOverride)) {
312 while (!this->DumpDir.empty() &&
314 this->DumpDir.pop_back();
321 std::string DumpPathStem;
323 << DumpDir << (DumpDir.empty() ?
"" :
"/") << getBufferIdentifier(*Obj);
325 std::string DumpPath = DumpPathStem +
".o";
333 <<
" -- " << (
const void *)(Obj->getBufferEnd() - 1) <<
" ] to "
341 DumpStream.
write(Obj->getBufferStart(), Obj->getBufferSize());
343 return std::move(Obj);
347 if (!IdentifierOverride.empty())
348 return IdentifierOverride;
349 StringRef Identifier =
B.getBufferIdentifier();
350 Identifier.consume_back(
".o");
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
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
Memory true print Memory SSA Printer
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.
Represents a symbol that has been evaluated to an address already.
JITSymbolFlags getFlags() const
Return the flags for this symbol.
JITTargetAddress getAddress() const
Return the address of this symbol.
Flags for symbols in the JIT.
This interface provides simple read-only access to a block of memory, and provides simple methods for...
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.
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.
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.
DenseMap< SymbolStringPtr, JITEvaluatedSymbol > SymbolMap
A map from symbol names (as SymbolStringPtrs) to JITSymbols (address/flags pairs).
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.
DenseMap< JITDylib *, SymbolNameSet > SymbolDependenceMap
A map from JITDylibs to sets of symbols.
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.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
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.