mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
[ViewCFG] Allow printing edge weights in debuggers
Summary: Extending the Function::viewCFG prototypes to allow for printing block probability info in form of .dot files during debugging. Also avoiding an AV when no BFI/BPI available. Reviewers: wenlei, davidxl, knaumov Reviewed By: wenlei, davidxl Subscribers: MaskRay, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D77978
This commit is contained in:
parent
a3747adc9a
commit
cfaa908f1f
@ -64,11 +64,11 @@ public:
|
|||||||
DOTFuncInfo(const Function *F) : DOTFuncInfo(F, nullptr, nullptr, 0) {}
|
DOTFuncInfo(const Function *F) : DOTFuncInfo(F, nullptr, nullptr, 0) {}
|
||||||
|
|
||||||
DOTFuncInfo(const Function *F, const BlockFrequencyInfo *BFI,
|
DOTFuncInfo(const Function *F, const BlockFrequencyInfo *BFI,
|
||||||
BranchProbabilityInfo *BPI, uint64_t MaxFreq)
|
const BranchProbabilityInfo *BPI, uint64_t MaxFreq)
|
||||||
: F(F), BFI(BFI), BPI(BPI), MaxFreq(MaxFreq) {
|
: F(F), BFI(BFI), BPI(BPI), MaxFreq(MaxFreq) {
|
||||||
ShowHeat = false;
|
ShowHeat = false;
|
||||||
EdgeWeights = true;
|
EdgeWeights = !!BPI; // Print EdgeWeights when BPI is available.
|
||||||
RawWeights = true;
|
RawWeights = !!BFI; // Print RawWeights when BFI is available.
|
||||||
}
|
}
|
||||||
|
|
||||||
const BlockFrequencyInfo *getBFI() { return BFI; }
|
const BlockFrequencyInfo *getBFI() { return BFI; }
|
||||||
|
@ -55,6 +55,8 @@ template <typename T> class Optional;
|
|||||||
class raw_ostream;
|
class raw_ostream;
|
||||||
class Type;
|
class Type;
|
||||||
class User;
|
class User;
|
||||||
|
class BranchProbabilityInfo;
|
||||||
|
class BlockFrequencyInfo;
|
||||||
|
|
||||||
class Function : public GlobalObject, public ilist_node<Function> {
|
class Function : public GlobalObject, public ilist_node<Function> {
|
||||||
public:
|
public:
|
||||||
@ -792,6 +794,10 @@ public:
|
|||||||
///
|
///
|
||||||
void viewCFG() const;
|
void viewCFG() const;
|
||||||
|
|
||||||
|
/// Extended form to print edge weights.
|
||||||
|
void viewCFG(bool ViewCFGOnly, const BlockFrequencyInfo *BFI,
|
||||||
|
const BranchProbabilityInfo *BPI) const;
|
||||||
|
|
||||||
/// viewCFGOnly - This function is meant for use from the debugger. It works
|
/// 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
|
/// just like viewCFG, but it does not include the contents of basic blocks
|
||||||
/// into the nodes, just the label. If you are only interested in the CFG
|
/// into the nodes, just the label. If you are only interested in the CFG
|
||||||
@ -799,6 +805,10 @@ public:
|
|||||||
///
|
///
|
||||||
void viewCFGOnly() const;
|
void viewCFGOnly() const;
|
||||||
|
|
||||||
|
/// Extended form to print edge weights.
|
||||||
|
void viewCFGOnly(const BlockFrequencyInfo *BFI,
|
||||||
|
const BranchProbabilityInfo *BPI) const;
|
||||||
|
|
||||||
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||||
static bool classof(const Value *V) {
|
static bool classof(const Value *V) {
|
||||||
return V->getValueID() == Value::FunctionVal;
|
return V->getValueID() == Value::FunctionVal;
|
||||||
|
@ -77,8 +77,8 @@ static void writeCFGToDotFile(Function &F, BlockFrequencyInfo *BFI,
|
|||||||
errs() << "\n";
|
errs() << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
static void viewCFG(Function &F, BlockFrequencyInfo *BFI,
|
static void viewCFG(Function &F, const BlockFrequencyInfo *BFI,
|
||||||
BranchProbabilityInfo *BPI, uint64_t MaxFreq,
|
const BranchProbabilityInfo *BPI, uint64_t MaxFreq,
|
||||||
bool CFGOnly = false) {
|
bool CFGOnly = false) {
|
||||||
DOTFuncInfo CFGInfo(&F, BFI, BPI, MaxFreq);
|
DOTFuncInfo CFGInfo(&F, BFI, BPI, MaxFreq);
|
||||||
CFGInfo.setHeatColors(ShowHeatColors);
|
CFGInfo.setHeatColors(ShowHeatColors);
|
||||||
@ -240,11 +240,14 @@ PreservedAnalyses CFGOnlyPrinterPass::run(Function &F,
|
|||||||
/// program, displaying the CFG of the current function. This depends on there
|
/// program, displaying the CFG of the current function. This depends on there
|
||||||
/// being a 'dot' and 'gv' program in your path.
|
/// being a 'dot' and 'gv' program in your path.
|
||||||
///
|
///
|
||||||
void Function::viewCFG() const {
|
void Function::viewCFG() const { viewCFG(false, nullptr, nullptr); }
|
||||||
|
|
||||||
|
void Function::viewCFG(bool ViewCFGOnly, const BlockFrequencyInfo *BFI,
|
||||||
|
const BranchProbabilityInfo *BPI) const {
|
||||||
if (!CFGFuncName.empty() && !getName().contains(CFGFuncName))
|
if (!CFGFuncName.empty() && !getName().contains(CFGFuncName))
|
||||||
return;
|
return;
|
||||||
DOTFuncInfo CFGInfo(this);
|
DOTFuncInfo CFGInfo(this, BFI, BPI, BFI ? getMaxFreq(*this, BFI) : 0);
|
||||||
ViewGraph(&CFGInfo, "cfg" + getName());
|
ViewGraph(&CFGInfo, "cfg" + getName(), ViewCFGOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// viewCFGOnly - This function is meant for use from the debugger. It works
|
/// viewCFGOnly - This function is meant for use from the debugger. It works
|
||||||
@ -252,11 +255,11 @@ void Function::viewCFG() const {
|
|||||||
/// into the nodes, just the label. If you are only interested in the CFG
|
/// into the nodes, just the label. If you are only interested in the CFG
|
||||||
/// this can make the graph smaller.
|
/// this can make the graph smaller.
|
||||||
///
|
///
|
||||||
void Function::viewCFGOnly() const {
|
void Function::viewCFGOnly() const { viewCFGOnly(nullptr, nullptr); }
|
||||||
if (!CFGFuncName.empty() && !getName().contains(CFGFuncName))
|
|
||||||
return;
|
void Function::viewCFGOnly(const BlockFrequencyInfo *BFI,
|
||||||
DOTFuncInfo CFGInfo(this);
|
const BranchProbabilityInfo *BPI) const {
|
||||||
ViewGraph(&CFGInfo, "cfg" + getName(), true);
|
viewCFG(true, BFI, BPI);
|
||||||
}
|
}
|
||||||
|
|
||||||
FunctionPass *llvm::createCFGPrinterLegacyPassPass() {
|
FunctionPass *llvm::createCFGPrinterLegacyPassPass() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user