Index: lib/Analysis/BlockFrequencyInfo.cpp =================================================================== --- lib/Analysis/BlockFrequencyInfo.cpp +++ lib/Analysis/BlockFrequencyInfo.cpp @@ -75,6 +75,15 @@ "display to only one function, use filtering option " "-view-bfi-func-name.")); +static cl::opt PrintBlockFreq( + "print-bfi", cl::init(false), cl::Hidden, + cl::desc("Print the block frequency info.")); + +cl::opt PrintBlockFreqFuncName( + "print-bfi-func-name", cl::Hidden, + cl::desc("The option to specify the name of the function " + "whose block frequency info is printed.")); + namespace llvm { static GVDAGType getGVDT() { @@ -180,6 +189,11 @@ F.getName().equals(ViewBlockFreqFuncName))) { view(); } + if (PrintBlockFreq && + (PrintBlockFreqFuncName.empty() || + F.getName().equals(PrintBlockFreqFuncName))) { + print(dbgs()); + } } BlockFrequency BlockFrequencyInfo::getBlockFreq(const BasicBlock *BB) const { Index: lib/Analysis/BranchProbabilityInfo.cpp =================================================================== --- lib/Analysis/BranchProbabilityInfo.cpp +++ lib/Analysis/BranchProbabilityInfo.cpp @@ -44,6 +44,15 @@ #define DEBUG_TYPE "branch-prob" +static cl::opt PrintBranchProb( + "print-bpi", cl::init(false), cl::Hidden, + cl::desc("Print the branch probability info.")); + +cl::opt PrintBranchProbFuncName( + "print-bpi-func-name", cl::Hidden, + cl::desc("The option to specify the name of the function " + "whose branch probability info is printed.")); + INITIALIZE_PASS_BEGIN(BranchProbabilityInfoWrapperPass, "branch-prob", "Branch Probability Analysis", false, true) INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass) @@ -790,6 +799,12 @@ PostDominatedByUnreachable.clear(); PostDominatedByColdCall.clear(); + + if (PrintBranchProb && + (PrintBranchProbFuncName.empty() || + F.getName().equals(PrintBranchProbFuncName))) { + print(dbgs()); + } } void BranchProbabilityInfoWrapperPass::getAnalysisUsage( Index: lib/CodeGen/MachineBlockFrequencyInfo.cpp =================================================================== --- lib/CodeGen/MachineBlockFrequencyInfo.cpp +++ lib/CodeGen/MachineBlockFrequencyInfo.cpp @@ -68,6 +68,14 @@ // Defined in Analysis/BlockFrequencyInfo.cpp: -view-hot-freq-perc= extern cl::opt ViewHotFreqPercent; +static cl::opt PrintMachineBlockFreq( + "print-machine-bfi", cl::init(false), cl::Hidden, + cl::desc("Print the machine block frequency info.")); + +// Command line option to specify the name of the function for block frequency +// dump. Defined in Analysis/BlockFrequencyInfo.cpp. +extern cl::opt PrintBlockFreqFuncName; + static GVDAGType getGVDT() { if (ViewBlockLayoutWithBFI != GVDT_None) return ViewBlockLayoutWithBFI; @@ -185,6 +193,11 @@ F.getName().equals(ViewBlockFreqFuncName))) { view("MachineBlockFrequencyDAGS." + F.getName()); } + if (PrintMachineBlockFreq && + (PrintBlockFreqFuncName.empty() || + F.getName().equals(PrintBlockFreqFuncName))) { + MBFI->print(dbgs()); + } } bool MachineBlockFrequencyInfo::runOnMachineFunction(MachineFunction &F) {