Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
11 changes: 10 additions & 1 deletion llvm/include/llvm/IR/Function.h
Original file line number Diff line number Diff line change
Expand Up @@ -942,9 +942,14 @@ class LLVM_ABI Function : public GlobalObject, public ilist_node<Function> {
///
void viewCFG() const;

/// viewCFG - This function is meant for use from the debugger. It works just
/// like viewCFG(), but generates the dot file with the given filename.
void viewCFG(const char *Name) const;

/// Extended form to print edge weights.
void viewCFG(bool ViewCFGOnly, const BlockFrequencyInfo *BFI,
const BranchProbabilityInfo *BPI) const;
const BranchProbabilityInfo *BPI,
const char *Name = nullptr) const;

/// viewCFGOnly - This function is meant for use from the debugger. It works
/// just like viewCFG, but it does not include the contents of basic blocks
Expand All @@ -953,6 +958,10 @@ class LLVM_ABI Function : public GlobalObject, public ilist_node<Function> {
///
void viewCFGOnly() const;

/// viewCFG - This function is meant for use from the debugger. It works just
/// like viewCFGOnly(), but generates the dot file with the given filename.
void viewCFGOnly(const char *Name) const;

/// Extended form to print edge weights.
void viewCFGOnly(const BlockFrequencyInfo *BFI,
const BranchProbabilityInfo *BPI) const;
Expand Down
13 changes: 11 additions & 2 deletions llvm/lib/Analysis/CFGPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,17 @@ PreservedAnalyses CFGOnlyPrinterPass::run(Function &F,
///
void Function::viewCFG() const { viewCFG(false, nullptr, nullptr); }

void Function::viewCFG(const char *Name) const {
viewCFG(false, nullptr, nullptr, Name);
}

void Function::viewCFG(bool ViewCFGOnly, const BlockFrequencyInfo *BFI,
const BranchProbabilityInfo *BPI) const {
const BranchProbabilityInfo *BPI,
const char *Name) const {
if (!CFGFuncName.empty() && !getName().contains(CFGFuncName))
return;
DOTFuncInfo CFGInfo(this, BFI, BPI, BFI ? getMaxFreq(*this, BFI) : 0);
ViewGraph(&CFGInfo, "cfg" + getName(), ViewCFGOnly);
ViewGraph(&CFGInfo, Name ? Name : "cfg" + getName(), ViewCFGOnly);
}

/// viewCFGOnly - This function is meant for use from the debugger. It works
Expand All @@ -151,6 +156,10 @@ void Function::viewCFG(bool ViewCFGOnly, const BlockFrequencyInfo *BFI,
///
void Function::viewCFGOnly() const { viewCFGOnly(nullptr, nullptr); }

void Function::viewCFGOnly(const char *Name) const {
viewCFG(true, nullptr, nullptr, Name);
}

void Function::viewCFGOnly(const BlockFrequencyInfo *BFI,
const BranchProbabilityInfo *BPI) const {
viewCFG(true, BFI, BPI);
Expand Down
Loading