Skip to content

[CFGPrinter] Added command line option to change DOT font #148403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
12 changes: 10 additions & 2 deletions llvm/include/llvm/Analysis/CFGPrinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@
#include "llvm/IR/Instructions.h"
#include "llvm/IR/PassManager.h"
#include "llvm/IR/ProfDataUtils.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/DOTGraphTraits.h"
#include "llvm/Support/FormatVariadic.h"

namespace llvm {
LLVM_ABI extern cl::opt<std::string> CFGFontName;

class ModuleSlotTracker;

template <class GraphType> struct GraphTraits;
Expand Down Expand Up @@ -321,9 +324,14 @@ struct DOTGraphTraits<DOTFuncInfo *> : public DefaultDOTGraphTraits {
? (getHeatColor(0))
: (getHeatColor(1));

std::string FontName = "Courier";
if (!CFGFontName.empty()) {
FontName = CFGFontName;
}

std::string Attrs = "color=\"" + EdgeColor + "ff\", style=filled," +
" fillcolor=\"" + Color + "70\"" +
" fontname=\"Courier\"";
" fillcolor=\"" + Color + "70\"" + " fontname=\"" +
FontName + "\"";
return Attrs;
}
LLVM_ABI bool isNodeHidden(const BasicBlock *Node,
Expand Down
5 changes: 5 additions & 0 deletions llvm/lib/Analysis/CFGPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@

using namespace llvm;

cl::opt<std::string>
llvm::CFGFontName("cfg-fontname", cl::Hidden,
cl::desc("The name of a font to use for the DOT"
" file (defaults to Courier)"));

static cl::opt<std::string>
CFGFuncName("cfg-func-name", cl::Hidden,
cl::desc("The name of a function (or its substring)"
Expand Down