From fd3f645f9de1ac0461577c872162f5977abcc329 Mon Sep 17 00:00:00 2001 From: Xinliang David Li Date: Sun, 29 Jan 2017 01:57:02 +0000 Subject: Add support to dump dot graph block layout after MBP Differential Revision: https://reviews.llvm.org/D29141 llvm-svn: 293408 --- llvm/lib/CodeGen/MachineBlockPlacement.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'llvm/lib/CodeGen/MachineBlockPlacement.cpp') diff --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp index 40e3840e6b0..7d57cc0956d 100644 --- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp +++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp @@ -32,6 +32,7 @@ #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Statistic.h" +#include "llvm/Analysis/BlockFrequencyInfoImpl.h" #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/CodeGen/MachineBlockFrequencyInfo.h" #include "llvm/CodeGen/MachineBranchProbabilityInfo.h" @@ -146,6 +147,11 @@ static cl::opt TailDuplicatePlacementThreshold( extern cl::opt StaticLikelyProb; extern cl::opt ProfileLikelyProb; +#ifndef NDEBUG +extern cl::opt ViewBlockLayoutWithBFI; +extern cl::opt ViewBlockFreqFuncName; +#endif + namespace { class BlockChain; /// \brief Type for our function-wide basic block -> block chain mapping. @@ -2067,6 +2073,14 @@ bool MachineBlockPlacement::runOnMachineFunction(MachineFunction &MF) { MBI->setAlignment(AlignAllNonFallThruBlocks); } } +#ifndef NDEBUG + if (ViewBlockLayoutWithBFI != GVDT_None && + (ViewBlockFreqFuncName.empty() || + F->getFunction()->getName().equals(ViewBlockFreqFuncName))) { + MBFI->view(false); + } +#endif + // We always return true as we have no way to track whether the final order // differs from the original order. -- cgit v1.2.3