Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions llvm/lib/ExecutionEngine/JITLink/JITLink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ std::vector<Block *> LinkGraph::splitBlockImpl(std::vector<Block *> Blocks,
void LinkGraph::dump(raw_ostream &OS) {
DenseMap<Block *, std::vector<Symbol *>> BlockSymbols;

OS << "LinkGraph \"" << getName()
<< "\" (triple = " << getTargetTriple().str() << ")\n";

// Map from blocks to the symbols pointing at them.
for (auto *Sym : defined_symbols())
BlockSymbols[&Sym->getBlock()].push_back(Sym);
Expand Down
30 changes: 12 additions & 18 deletions llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,21 @@ JITLinkerBase::~JITLinkerBase() = default;

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

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

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

LLVM_DEBUG({
dbgs() << "Link graph \"" << G->getName() << "\" pre-pruning:\n";
dbgs() << "Link graph pre-pruning:\n";
G->dump(dbgs());
});

prune(*G);

LLVM_DEBUG({
dbgs() << "Link graph \"" << G->getName() << "\" post-pruning:\n";
dbgs() << "Link graph post-pruning:\n";
G->dump(dbgs());
});

Expand Down Expand Up @@ -67,14 +65,15 @@ void JITLinkerBase::linkPhase1(std::unique_ptr<JITLinkerBase> Self) {
void JITLinkerBase::linkPhase2(std::unique_ptr<JITLinkerBase> Self,
AllocResult AR) {

LLVM_DEBUG(dbgs() << "Starting link phase 2\n");

if (AR)
Alloc = std::move(*AR);
else
return Ctx->notifyFailed(AR.takeError());

LLVM_DEBUG({
dbgs() << "Link graph \"" << G->getName()
<< "\" before post-allocation passes:\n";
dbgs() << "Link graph before post-allocation passes:\n";
G->dump(dbgs());
});

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

LLVM_DEBUG({
dbgs() << "Starting link phase 3 for graph " << G->getName() << "\n";
});
LLVM_DEBUG(dbgs() << "Starting link phase 3\n");

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

LLVM_DEBUG({
dbgs() << "Link graph \"" << G->getName()
<< "\" before pre-fixup passes:\n";
dbgs() << "Link graph before pre-fixup passes:\n";
G->dump(dbgs());
});

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

LLVM_DEBUG({
dbgs() << "Link graph \"" << G->getName() << "\" before copy-and-fixup:\n";
dbgs() << "Link graph before copy-and-fixup:\n";
G->dump(dbgs());
});

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

LLVM_DEBUG({
dbgs() << "Link graph \"" << G->getName() << "\" after copy-and-fixup:\n";
dbgs() << "Link graph after copy-and-fixup:\n";
G->dump(dbgs());
});

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

LLVM_DEBUG({
dbgs() << "Starting link phase 4 for graph " << G->getName() << "\n";
});
LLVM_DEBUG(dbgs() << "Starting link phase 4\n");

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

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

LLVM_DEBUG({ dbgs() << "Link of graph " << G->getName() << " complete\n"; });
LLVM_DEBUG({ dbgs() << "Link complete\n"; });
}

Error JITLinkerBase::runPasses(LinkGraphPassList &Passes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# CHECK-OBJ: Contents of section .rodata:
# CHECK-OBJ: 0000 48310048 32004833 00 H1.H2.H3.

# CHECK-LG: Starting link phase 1 for graph
# CHECK-LG: Starting link phase 1
# CHECK-LG: section .rodata:

# CHECK-LG: block 0x0 size = 0x00000009, align = 1, alignment-offset = 0
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/ExecutionEngine/JITLink/RISCV/ELF_relax_call.s
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ p:
call o
.size p, .-p

# CHECK: Link graph "{{.*}}" before copy-and-fixup:
# CHECK: Link graph before copy-and-fixup:
# CHECK: section .text:
# CHECK: block 0x1000
# CHECK: symbols:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ p:
call o
.size p, .-p

# CHECK: Link graph "{{.*}}" before copy-and-fixup:
# CHECK: Link graph before copy-and-fixup:
# CHECK: section .text:
# CHECK: block 0x1000
# CHECK: symbols:
Expand Down