Skip to content

Commit a7016c4

Browse files
authored
[JITLink] Add LinkGraph name / triple to debugging output. (#161772)
Adds the name and triple of the graph to LinkGraph::dump output before the rest of the graph content. Calls from JITLinkGeneric.cpp to dump the graph are updated to avoid redundantly naming the graph.
1 parent d7f1cc8 commit a7016c4

File tree

5 files changed

+18
-21
lines changed

5 files changed

+18
-21
lines changed

llvm/lib/ExecutionEngine/JITLink/JITLink.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,9 @@ std::vector<Block *> LinkGraph::splitBlockImpl(std::vector<Block *> Blocks,
280280
void LinkGraph::dump(raw_ostream &OS) {
281281
DenseMap<Block *, std::vector<Symbol *>> BlockSymbols;
282282

283+
OS << "LinkGraph \"" << getName()
284+
<< "\" (triple = " << getTargetTriple().str() << ")\n";
285+
283286
// Map from blocks to the symbols pointing at them.
284287
for (auto *Sym : defined_symbols())
285288
BlockSymbols[&Sym->getBlock()].push_back(Sym);

llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.cpp

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,21 @@ JITLinkerBase::~JITLinkerBase() = default;
2121

2222
void JITLinkerBase::linkPhase1(std::unique_ptr<JITLinkerBase> Self) {
2323

24-
LLVM_DEBUG({
25-
dbgs() << "Starting link phase 1 for graph " << G->getName() << "\n";
26-
});
24+
LLVM_DEBUG(dbgs() << "Starting link phase 1\n");
2725

2826
// Prune and optimize the graph.
2927
if (auto Err = runPasses(Passes.PrePrunePasses))
3028
return Ctx->notifyFailed(std::move(Err));
3129

3230
LLVM_DEBUG({
33-
dbgs() << "Link graph \"" << G->getName() << "\" pre-pruning:\n";
31+
dbgs() << "Link graph pre-pruning:\n";
3432
G->dump(dbgs());
3533
});
3634

3735
prune(*G);
3836

3937
LLVM_DEBUG({
40-
dbgs() << "Link graph \"" << G->getName() << "\" post-pruning:\n";
38+
dbgs() << "Link graph post-pruning:\n";
4139
G->dump(dbgs());
4240
});
4341

@@ -67,14 +65,15 @@ void JITLinkerBase::linkPhase1(std::unique_ptr<JITLinkerBase> Self) {
6765
void JITLinkerBase::linkPhase2(std::unique_ptr<JITLinkerBase> Self,
6866
AllocResult AR) {
6967

68+
LLVM_DEBUG(dbgs() << "Starting link phase 2\n");
69+
7070
if (AR)
7171
Alloc = std::move(*AR);
7272
else
7373
return Ctx->notifyFailed(AR.takeError());
7474

7575
LLVM_DEBUG({
76-
dbgs() << "Link graph \"" << G->getName()
77-
<< "\" before post-allocation passes:\n";
76+
dbgs() << "Link graph before post-allocation passes:\n";
7877
G->dump(dbgs());
7978
});
8079

@@ -131,9 +130,7 @@ void JITLinkerBase::linkPhase2(std::unique_ptr<JITLinkerBase> Self,
131130
void JITLinkerBase::linkPhase3(std::unique_ptr<JITLinkerBase> Self,
132131
Expected<AsyncLookupResult> LR) {
133132

134-
LLVM_DEBUG({
135-
dbgs() << "Starting link phase 3 for graph " << G->getName() << "\n";
136-
});
133+
LLVM_DEBUG(dbgs() << "Starting link phase 3\n");
137134

138135
// If the lookup failed, bail out.
139136
if (!LR)
@@ -143,16 +140,15 @@ void JITLinkerBase::linkPhase3(std::unique_ptr<JITLinkerBase> Self,
143140
applyLookupResult(*LR);
144141

145142
LLVM_DEBUG({
146-
dbgs() << "Link graph \"" << G->getName()
147-
<< "\" before pre-fixup passes:\n";
143+
dbgs() << "Link graph before pre-fixup passes:\n";
148144
G->dump(dbgs());
149145
});
150146

151147
if (auto Err = runPasses(Passes.PreFixupPasses))
152148
return abandonAllocAndBailOut(std::move(Self), std::move(Err));
153149

154150
LLVM_DEBUG({
155-
dbgs() << "Link graph \"" << G->getName() << "\" before copy-and-fixup:\n";
151+
dbgs() << "Link graph before copy-and-fixup:\n";
156152
G->dump(dbgs());
157153
});
158154

@@ -161,7 +157,7 @@ void JITLinkerBase::linkPhase3(std::unique_ptr<JITLinkerBase> Self,
161157
return abandonAllocAndBailOut(std::move(Self), std::move(Err));
162158

163159
LLVM_DEBUG({
164-
dbgs() << "Link graph \"" << G->getName() << "\" after copy-and-fixup:\n";
160+
dbgs() << "Link graph after copy-and-fixup:\n";
165161
G->dump(dbgs());
166162
});
167163

@@ -186,16 +182,14 @@ void JITLinkerBase::linkPhase3(std::unique_ptr<JITLinkerBase> Self,
186182
void JITLinkerBase::linkPhase4(std::unique_ptr<JITLinkerBase> Self,
187183
FinalizeResult FR) {
188184

189-
LLVM_DEBUG({
190-
dbgs() << "Starting link phase 4 for graph " << G->getName() << "\n";
191-
});
185+
LLVM_DEBUG(dbgs() << "Starting link phase 4\n");
192186

193187
if (!FR)
194188
return Ctx->notifyFailed(FR.takeError());
195189

196190
Ctx->notifyFinalized(std::move(*FR));
197191

198-
LLVM_DEBUG({ dbgs() << "Link of graph " << G->getName() << " complete\n"; });
192+
LLVM_DEBUG({ dbgs() << "Link complete\n"; });
199193
}
200194

201195
Error JITLinkerBase::runPasses(LinkGraphPassList &Passes) {

llvm/test/ExecutionEngine/JITLink/AArch32/ELF_data_alignment.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
# CHECK-OBJ: Contents of section .rodata:
2323
# CHECK-OBJ: 0000 48310048 32004833 00 H1.H2.H3.
2424

25-
# CHECK-LG: Starting link phase 1 for graph
25+
# CHECK-LG: Starting link phase 1
2626
# CHECK-LG: section .rodata:
2727

2828
# CHECK-LG: block 0x0 size = 0x00000009, align = 1, alignment-offset = 0

llvm/test/ExecutionEngine/JITLink/RISCV/ELF_relax_call.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ p:
102102
call o
103103
.size p, .-p
104104

105-
# CHECK: Link graph "{{.*}}" before copy-and-fixup:
105+
# CHECK: Link graph before copy-and-fixup:
106106
# CHECK: section .text:
107107
# CHECK: block 0x1000
108108
# CHECK: symbols:

llvm/test/ExecutionEngine/JITLink/RISCV/ELF_relax_call_rvc.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ p:
131131
call o
132132
.size p, .-p
133133

134-
# CHECK: Link graph "{{.*}}" before copy-and-fixup:
134+
# CHECK: Link graph before copy-and-fixup:
135135
# CHECK: section .text:
136136
# CHECK: block 0x1000
137137
# CHECK: symbols:

0 commit comments

Comments
 (0)