mirror of
https://github.com/intel/llvm.git
synced 2026-01-17 14:48:27 +08:00
[BOLT] Add -dump-cg option to dump call graph
Reviewed By: #bolt, rafauler Differential Revision: https://reviews.llvm.org/D153994
This commit is contained in:
@@ -148,7 +148,7 @@ public:
|
||||
// samples for every node
|
||||
void adjustArcWeights();
|
||||
|
||||
template <typename L> void printDot(char *fileName, L getLabel) const;
|
||||
template <typename L> void printDot(StringRef FileName, L getLabel) const;
|
||||
|
||||
private:
|
||||
void setSamples(const NodeId Id, uint64_t Samples) {
|
||||
@@ -160,9 +160,10 @@ private:
|
||||
ArcsType Arcs;
|
||||
};
|
||||
|
||||
template <class L> void CallGraph::printDot(char *FileName, L GetLabel) const {
|
||||
template <class L>
|
||||
void CallGraph::printDot(StringRef FileName, L GetLabel) const {
|
||||
std::error_code EC;
|
||||
raw_fd_ostream OS(std::string(FileName), EC, sys::fs::OF_None);
|
||||
raw_fd_ostream OS(FileName, EC, sys::fs::OF_None);
|
||||
if (EC)
|
||||
return;
|
||||
|
||||
|
||||
@@ -19,9 +19,18 @@
|
||||
|
||||
#define DEBUG_TYPE "callgraph"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
namespace opts {
|
||||
extern llvm::cl::opt<bool> TimeOpts;
|
||||
extern llvm::cl::opt<unsigned> Verbosity;
|
||||
|
||||
extern cl::opt<bool> TimeOpts;
|
||||
extern cl::opt<unsigned> Verbosity;
|
||||
extern cl::OptionCategory BoltCategory;
|
||||
|
||||
static cl::opt<std::string>
|
||||
DumpCGDot("dump-cg", cl::desc("dump callgraph to the given file"),
|
||||
cl::cat(BoltCategory));
|
||||
|
||||
} // namespace opts
|
||||
|
||||
namespace llvm {
|
||||
@@ -277,6 +286,12 @@ buildCallGraph(BinaryContext &BC, CgFilterFunction Filter, bool CgFromPerfData,
|
||||
Cg.density(), NotProcessed, NoProfileCallsites,
|
||||
NumFallbacks);
|
||||
|
||||
if (opts::DumpCGDot.getNumOccurrences()) {
|
||||
Cg.printDot(opts::DumpCGDot, [&](CallGraph::NodeId Id) {
|
||||
return Cg.nodeIdToFunc(Id)->getPrintName();
|
||||
});
|
||||
}
|
||||
|
||||
return Cg;
|
||||
}
|
||||
|
||||
|
||||
@@ -172,9 +172,9 @@ cl::opt<bool>
|
||||
|
||||
cl::cat(BoltCategory));
|
||||
|
||||
llvm::cl::opt<bool> TimeOpts("time-opts",
|
||||
cl::desc("print time spent in each optimization"),
|
||||
cl::cat(BoltOptCategory));
|
||||
cl::opt<bool> TimeOpts("time-opts",
|
||||
cl::desc("print time spent in each optimization"),
|
||||
cl::cat(BoltOptCategory));
|
||||
|
||||
cl::opt<bool> UseOldText(
|
||||
"use-old-text",
|
||||
|
||||
Reference in New Issue
Block a user