Skip to content

Commit

Permalink
[BOLT][NFC] Add extra debug logging to buildCallGraph
Browse files Browse the repository at this point in the history
Reviewed By: #bolt, rafauler

Differential Revision: https://reviews.llvm.org/D153987
  • Loading branch information
aaupov committed Jun 29, 2023
1 parent fd49cc8 commit 3fe2c21
Showing 1 changed file with 30 additions and 23 deletions.
53 changes: 30 additions & 23 deletions bolt/lib/Passes/BinaryFunctionCallGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,32 +135,39 @@ buildCallGraph(BinaryContext &BC, CgFilterFunction Filter, bool CgFromPerfData,
uint64_t Offset = 0;

auto recordCall = [&](const MCSymbol *DestSymbol, const uint64_t Count) {
if (BinaryFunction *DstFunc =
DestSymbol ? BC.getFunctionForSymbol(DestSymbol) : nullptr) {
if (DstFunc == Function) {
LLVM_DEBUG(dbgs() << "BOLT-INFO: recursive call detected in "
<< *DstFunc << "\n");
++RecursiveCallsites;
if (IgnoreRecursiveCalls)
return false;
}
if (Filter(*DstFunc))
return false;
BinaryFunction *DstFunc =
DestSymbol ? BC.getFunctionForSymbol(DestSymbol) : nullptr;
if (!DstFunc) {
LLVM_DEBUG(if (opts::Verbosity > 1) dbgs()
<< "BOLT-DEBUG: buildCallGraph: no function for symbol\n");
return false;
}

const CallGraph::NodeId DstId = lookupNode(DstFunc);
const bool IsValidCount = Count != COUNT_NO_PROFILE;
const uint64_t AdjCount = UseEdgeCounts && IsValidCount ? Count : 1;
if (!IsValidCount)
++NoProfileCallsites;
Cg.incArcWeight(SrcId, DstId, AdjCount, Offset);
LLVM_DEBUG(if (opts::Verbosity > 1) {
dbgs() << "BOLT-DEBUG: buildCallGraph: call " << *Function << " -> "
<< *DstFunc << " @ " << Offset << "\n";
});
return true;
if (DstFunc == Function) {
LLVM_DEBUG(dbgs() << "BOLT-INFO: recursive call detected in "
<< *DstFunc << "\n");
++RecursiveCallsites;
if (IgnoreRecursiveCalls)
return false;
}
if (Filter(*DstFunc)) {
LLVM_DEBUG(if (opts::Verbosity > 1) dbgs()
<< "BOLT-DEBUG: buildCallGraph: filtered " << *DstFunc
<< '\n');
return false;
}

return false;
const CallGraph::NodeId DstId = lookupNode(DstFunc);
const bool IsValidCount = Count != COUNT_NO_PROFILE;
const uint64_t AdjCount = UseEdgeCounts && IsValidCount ? Count : 1;
if (!IsValidCount)
++NoProfileCallsites;
Cg.incArcWeight(SrcId, DstId, AdjCount, Offset);
LLVM_DEBUG(if (opts::Verbosity > 1) {
dbgs() << "BOLT-DEBUG: buildCallGraph: call " << *Function << " -> "
<< *DstFunc << " @ " << Offset << "\n";
});
return true;
};

// Pairs of (symbol, count) for each target at this callsite.
Expand Down

0 comments on commit 3fe2c21

Please sign in to comment.