Skip to content

Commit 38a8760

Browse files
committed
[ORC] Move ostream operators for debugging output out of Core.h.
DebugUtils.h seems like a more appropriate home for these.
1 parent a1e0275 commit 38a8760

File tree

7 files changed

+363
-344
lines changed

7 files changed

+363
-344
lines changed

llvm/include/llvm/ExecutionEngine/Orc/Core.h

+6-69
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
#include <memory>
2525
#include <vector>
2626

27-
#define DEBUG_TYPE "orc"
28-
2927
namespace llvm {
3028
namespace orc {
3129

@@ -309,66 +307,6 @@ struct SymbolAliasMapEntry {
309307
/// A map of Symbols to (Symbol, Flags) pairs.
310308
using SymbolAliasMap = DenseMap<SymbolStringPtr, SymbolAliasMapEntry>;
311309

312-
/// Render a SymbolStringPtr.
313-
raw_ostream &operator<<(raw_ostream &OS, const SymbolStringPtr &Sym);
314-
315-
/// Render a SymbolNameSet.
316-
raw_ostream &operator<<(raw_ostream &OS, const SymbolNameSet &Symbols);
317-
318-
/// Render a SymbolNameVector.
319-
raw_ostream &operator<<(raw_ostream &OS, const SymbolNameVector &Symbols);
320-
321-
/// Render a SymbolFlagsMap entry.
322-
raw_ostream &operator<<(raw_ostream &OS, const SymbolFlagsMap::value_type &KV);
323-
324-
/// Render a SymbolMap entry.
325-
raw_ostream &operator<<(raw_ostream &OS, const SymbolMap::value_type &KV);
326-
327-
/// Render a SymbolFlagsMap.
328-
raw_ostream &operator<<(raw_ostream &OS, const SymbolFlagsMap &SymbolFlags);
329-
330-
/// Render a SymbolMap.
331-
raw_ostream &operator<<(raw_ostream &OS, const SymbolMap &Symbols);
332-
333-
/// Render a SymbolDependenceMap entry.
334-
raw_ostream &operator<<(raw_ostream &OS,
335-
const SymbolDependenceMap::value_type &KV);
336-
337-
/// Render a SymbolDependendeMap.
338-
raw_ostream &operator<<(raw_ostream &OS, const SymbolDependenceMap &Deps);
339-
340-
/// Render a MaterializationUnit.
341-
raw_ostream &operator<<(raw_ostream &OS, const MaterializationUnit &MU);
342-
343-
//// Render a JITDylibLookupFlags instance.
344-
raw_ostream &operator<<(raw_ostream &OS,
345-
const JITDylibLookupFlags &JDLookupFlags);
346-
347-
/// Rendar a SymbolLookupFlags instance.
348-
raw_ostream &operator<<(raw_ostream &OS, const SymbolLookupFlags &LookupFlags);
349-
350-
/// Render a JITDylibLookupFlags instance.
351-
raw_ostream &operator<<(raw_ostream &OS, const LookupKind &K);
352-
353-
/// Render a SymbolLookupSet entry.
354-
raw_ostream &operator<<(raw_ostream &OS, const SymbolLookupSet::value_type &KV);
355-
356-
/// Render a SymbolLookupSet.
357-
raw_ostream &operator<<(raw_ostream &OS, const SymbolLookupSet &LookupSet);
358-
359-
/// Render a JITDylibSearchOrder.
360-
raw_ostream &operator<<(raw_ostream &OS,
361-
const JITDylibSearchOrder &SearchOrder);
362-
363-
/// Render a SymbolAliasMap.
364-
raw_ostream &operator<<(raw_ostream &OS, const SymbolAliasMap &Aliases);
365-
366-
/// Render a SymbolState.
367-
raw_ostream &operator<<(raw_ostream &OS, const SymbolState &S);
368-
369-
/// Render a LookupKind.
370-
raw_ostream &operator<<(raw_ostream &OS, const LookupKind &K);
371-
372310
/// Callback to notify client that symbols have been resolved.
373311
using SymbolsResolvedCallback = unique_function<void(Expected<SymbolMap>)>;
374312

@@ -1301,11 +1239,8 @@ class ExecutionSession {
13011239
/// Materialize the given unit.
13021240
void dispatchMaterialization(JITDylib &JD,
13031241
std::unique_ptr<MaterializationUnit> MU) {
1304-
LLVM_DEBUG({
1305-
runSessionLocked([&]() {
1306-
dbgs() << "Dispatching " << *MU << " for " << JD.getName() << "\n";
1307-
});
1308-
});
1242+
assert(MU && "MU must be non-null");
1243+
DEBUG_WITH_TYPE("orc", dumpDispatchInfo(JD, *MU));
13091244
DispatchMaterialization(JD, std::move(MU));
13101245
}
13111246

@@ -1325,6 +1260,10 @@ class ExecutionSession {
13251260

13261261
void runOutstandingMUs();
13271262

1263+
#ifndef NDEBUG
1264+
void dumpDispatchInfo(JITDylib &JD, MaterializationUnit &MU);
1265+
#endif // NDEBUG
1266+
13281267
mutable std::recursive_mutex SessionMutex;
13291268
std::shared_ptr<SymbolStringPool> SSP;
13301269
std::unique_ptr<Platform> P;
@@ -1425,6 +1364,4 @@ class ReexportsGenerator : public JITDylib::DefinitionGenerator {
14251364
} // End namespace orc
14261365
} // End namespace llvm
14271366

1428-
#undef DEBUG_TYPE // "orc"
1429-
14301367
#endif // LLVM_EXECUTIONENGINE_ORC_CORE_H

llvm/include/llvm/ExecutionEngine/Orc/DebugUtils.h

+69
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
#ifndef LLVM_EXECUTIONENGINE_ORC_DEBUGUTILS_H
1414
#define LLVM_EXECUTIONENGINE_ORC_DEBUGUTILS_H
1515

16+
#include "llvm/ADT/ArrayRef.h"
17+
#include "llvm/ExecutionEngine/Orc/Core.h"
18+
#include "llvm/ExecutionEngine/Orc/SymbolStringPool.h"
1619
#include "llvm/Support/Error.h"
20+
#include "llvm/Support/raw_ostream.h"
1721
#include <memory>
1822
#include <string>
1923

@@ -23,6 +27,71 @@ class MemoryBuffer;
2327

2428
namespace orc {
2529

30+
// --raw_ostream operators for ORC types--
31+
32+
/// Render a SymbolStringPtr.
33+
raw_ostream &operator<<(raw_ostream &OS, const SymbolStringPtr &Sym);
34+
35+
/// Render a SymbolNameSet.
36+
raw_ostream &operator<<(raw_ostream &OS, const SymbolNameSet &Symbols);
37+
38+
/// Render a SymbolNameVector.
39+
raw_ostream &operator<<(raw_ostream &OS, const SymbolNameVector &Symbols);
40+
41+
/// Render JITSymbolFlags.
42+
raw_ostream &operator<<(raw_ostream &OS, const JITSymbolFlags &Flags);
43+
44+
/// Render a SymbolFlagsMap entry.
45+
raw_ostream &operator<<(raw_ostream &OS, const SymbolFlagsMap::value_type &KV);
46+
47+
/// Render a SymbolMap entry.
48+
raw_ostream &operator<<(raw_ostream &OS, const SymbolMap::value_type &KV);
49+
50+
/// Render a SymbolFlagsMap.
51+
raw_ostream &operator<<(raw_ostream &OS, const SymbolFlagsMap &SymbolFlags);
52+
53+
/// Render a SymbolMap.
54+
raw_ostream &operator<<(raw_ostream &OS, const SymbolMap &Symbols);
55+
56+
/// Render a SymbolDependenceMap entry.
57+
raw_ostream &operator<<(raw_ostream &OS,
58+
const SymbolDependenceMap::value_type &KV);
59+
60+
/// Render a SymbolDependendeMap.
61+
raw_ostream &operator<<(raw_ostream &OS, const SymbolDependenceMap &Deps);
62+
63+
/// Render a MaterializationUnit.
64+
raw_ostream &operator<<(raw_ostream &OS, const MaterializationUnit &MU);
65+
66+
//// Render a JITDylibLookupFlags instance.
67+
raw_ostream &operator<<(raw_ostream &OS,
68+
const JITDylibLookupFlags &JDLookupFlags);
69+
70+
/// Rendar a SymbolLookupFlags instance.
71+
raw_ostream &operator<<(raw_ostream &OS, const SymbolLookupFlags &LookupFlags);
72+
73+
/// Render a JITDylibLookupFlags instance.
74+
raw_ostream &operator<<(raw_ostream &OS, const LookupKind &K);
75+
76+
/// Render a SymbolLookupSet entry.
77+
raw_ostream &operator<<(raw_ostream &OS, const SymbolLookupSet::value_type &KV);
78+
79+
/// Render a SymbolLookupSet.
80+
raw_ostream &operator<<(raw_ostream &OS, const SymbolLookupSet &LookupSet);
81+
82+
/// Render a JITDylibSearchOrder.
83+
raw_ostream &operator<<(raw_ostream &OS,
84+
const JITDylibSearchOrder &SearchOrder);
85+
86+
/// Render a SymbolAliasMap.
87+
raw_ostream &operator<<(raw_ostream &OS, const SymbolAliasMap &Aliases);
88+
89+
/// Render a SymbolState.
90+
raw_ostream &operator<<(raw_ostream &OS, const SymbolState &S);
91+
92+
/// Render a LookupKind.
93+
raw_ostream &operator<<(raw_ostream &OS, const LookupKind &K);
94+
2695
/// A function object that can be used as an ObjectTransformLayer transform
2796
/// to dump object files to disk at a specified path.
2897
class DumpObjects {

llvm/include/llvm/ExecutionEngine/Orc/Speculation.h

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "llvm/ADT/DenseMap.h"
1818
#include "llvm/ADT/Optional.h"
1919
#include "llvm/ExecutionEngine/Orc/Core.h"
20+
#include "llvm/ExecutionEngine/Orc/DebugUtils.h"
2021
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
2122
#include "llvm/IR/PassManager.h"
2223
#include "llvm/Passes/PassBuilder.h"

0 commit comments

Comments
 (0)