LLVM  4.0.0
Macros | Functions | Variables
MachineBlockPlacement.cpp File Reference
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/TargetPassConfig.h"
#include "BranchFolding.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineBlockFrequencyInfo.h"
#include "llvm/CodeGen/MachineBranchProbabilityInfo.h"
#include "llvm/CodeGen/MachineDominators.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineLoopInfo.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/CodeGen/TailDuplicator.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetInstrInfo.h"
#include "llvm/Target/TargetLowering.h"
#include "llvm/Target/TargetSubtargetInfo.h"
#include <algorithm>
Include dependency graph for MachineBlockPlacement.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "block-placement"
 

Functions

 STATISTIC (NumCondBranches,"Number of conditional branches")
 
 STATISTIC (NumUncondBranches,"Number of unconditional branches")
 
 STATISTIC (CondBranchTakenFreq,"Potential frequency of taking conditional branches")
 
 STATISTIC (UncondBranchTakenFreq,"Potential frequency of taking unconditional branches")
 
 INITIALIZE_PASS_BEGIN (MachineBlockPlacement,"block-placement","Branch Probability Basic Block Placement", false, false) INITIALIZE_PASS_END(MachineBlockPlacement
 
block Branch Probability Basic
Block static false std::string 
getBlockName (MachineBasicBlock *BB)
 Helper to print the name of a MBB. More...
 
static BranchProbability getAdjustedProbability (BranchProbability OrigProb, BranchProbability AdjustedSumProb)
 The helper function returns the branch probability that is adjusted or normalized over the new total AdjustedSumProb. More...
 
static BranchProbability getLayoutSuccessorProbThreshold (MachineBasicBlock *BB)
 
 INITIALIZE_PASS_BEGIN (MachineBlockPlacementStats,"block-placement-stats","Basic Block Placement Stats", false, false) INITIALIZE_PASS_END(MachineBlockPlacementStats
 

Variables

static cl::opt< unsignedAlignAllBlock ("align-all-blocks", cl::desc("Force the alignment of all ""blocks in the function."), cl::init(0), cl::Hidden)
 
static cl::opt< unsignedAlignAllNonFallThruBlocks ("align-all-nofallthru-blocks", cl::desc("Force the alignment of all ""blocks that have no fall-through predecessors (i.e. don't add ""nops that are executed)."), cl::init(0), cl::Hidden)
 
static cl::opt< unsignedExitBlockBias ("block-placement-exit-block-bias", cl::desc("Block frequency percentage a loop exit block needs ""over the original exit to be considered the new exit."), cl::init(0), cl::Hidden)
 
static cl::opt< boolOutlineOptionalBranches ("outline-optional-branches", cl::desc("Outlining optional branches will place blocks that are optional ""branches, i.e. branches with a common post dominator, outside ""the hot path or chain"), cl::init(false), cl::Hidden)
 
static cl::opt< unsignedOutlineOptionalThreshold ("outline-optional-threshold", cl::desc("Don't outline optional branches that are a single block with an ""instruction count below this threshold"), cl::init(4), cl::Hidden)
 
static cl::opt< unsignedLoopToColdBlockRatio ("loop-to-cold-block-ratio", cl::desc("Outline loop blocks from loop chain if (frequency of loop) / ""(frequency of block) is greater than this ratio"), cl::init(5), cl::Hidden)
 
static cl::opt< boolPreciseRotationCost ("precise-rotation-cost", cl::desc("Model the cost of loop rotation more ""precisely by using profile data."), cl::init(false), cl::Hidden)
 
static cl::opt< boolForcePreciseRotationCost ("force-precise-rotation-cost", cl::desc("Force the use of precise cost ""loop rotation strategy."), cl::init(false), cl::Hidden)
 
static cl::opt< unsignedMisfetchCost ("misfetch-cost", cl::desc("Cost that models the probabilistic risk of an instruction ""misfetch due to a jump comparing to falling through, whose cost ""is zero."), cl::init(1), cl::Hidden)
 
static cl::opt< unsignedJumpInstCost ("jump-inst-cost", cl::desc("Cost of jump instructions."), cl::init(1), cl::Hidden)
 
static cl::opt< boolTailDupPlacement ("tail-dup-placement", cl::desc("Perform tail duplication during placement. ""Creates more fallthrough opportunites in ""outline branches."), cl::init(true), cl::Hidden)
 
static cl::opt< boolBranchFoldPlacement ("branch-fold-placement", cl::desc("Perform branch folding during placement. ""Reduces code size."), cl::init(true), cl::Hidden)
 
static cl::opt< unsignedTailDuplicatePlacementThreshold ("tail-dup-placement-threshold", cl::desc("Instruction cutoff for tail duplication during layout. ""Tail merging during layout is forced to have a threshold ""that won't conflict."), cl::init(2), cl::Hidden)
 
cl::opt< unsignedStaticLikelyProb
 
cl::opt< unsignedProfileLikelyProb
 
block placement
 
block Branch Probability Basic
Block 
Placement
 
block Branch Probability Basic
Block 
false
 
block placement stats
 
block placement Basic Block
Placement 
Stats
 

Macro Definition Documentation

#define DEBUG_TYPE   "block-placement"

Definition at line 54 of file MachineBlockPlacement.cpp.

Function Documentation

static BranchProbability getAdjustedProbability ( BranchProbability  OrigProb,
BranchProbability  AdjustedSumProb 
)
static

The helper function returns the branch probability that is adjusted or normalized over the new total AdjustedSumProb.

Definition at line 551 of file MachineBlockPlacement.cpp.

References llvm::BranchProbability::getNumerator(), and llvm::BranchProbability::getOne().

block Branch Probability Basic Block static false std::string getBlockName ( MachineBasicBlock BB)
static

Helper to print the name of a MBB.

Only used by debug logging.

Definition at line 441 of file MachineBlockPlacement.cpp.

References llvm::raw_ostream::flush(), llvm::MachineBasicBlock::getName(), and llvm::MachineBasicBlock::getNumber().

static BranchProbability getLayoutSuccessorProbThreshold ( MachineBasicBlock BB)
static
INITIALIZE_PASS_BEGIN ( MachineBlockPlacement  ,
"block-placement ,
"Branch Probability Basic Block Placement ,
false  ,
false   
)
INITIALIZE_PASS_BEGIN ( MachineBlockPlacementStats  ,
"block-placement-stats ,
"Basic Block Placement Stats ,
false  ,
false   
)
STATISTIC ( NumCondBranches  ,
"Number of conditional branches"   
)
STATISTIC ( NumUncondBranches  ,
"Number of unconditional branches"   
)
STATISTIC ( CondBranchTakenFreq  ,
"Potential frequency of taking conditional branches"   
)
STATISTIC ( UncondBranchTakenFreq  ,
"Potential frequency of taking unconditional branches"   
)

Variable Documentation

cl::opt<unsigned> AlignAllBlock("align-all-blocks", cl::desc("Force the alignment of all ""blocks in the function."), cl::init(0), cl::Hidden)
static
cl::opt<unsigned> AlignAllNonFallThruBlocks("align-all-nofallthru-blocks", cl::desc("Force the alignment of all ""blocks that have no fall-through predecessors (i.e. don't add ""nops that are executed)."), cl::init(0), cl::Hidden)
static
cl::opt<bool> BranchFoldPlacement("branch-fold-placement", cl::desc("Perform branch folding during placement. ""Reduces code size."), cl::init(true), cl::Hidden)
static
cl::opt<unsigned> ExitBlockBias("block-placement-exit-block-bias", cl::desc("Block frequency percentage a loop exit block needs ""over the original exit to be considered the new exit."), cl::init(0), cl::Hidden)
static
block placement Basic Block Placement false

Definition at line 434 of file MachineBlockPlacement.cpp.

cl::opt<bool> ForcePreciseRotationCost("force-precise-rotation-cost", cl::desc("Force the use of precise cost ""loop rotation strategy."), cl::init(false), cl::Hidden)
static
cl::opt<unsigned> JumpInstCost("jump-inst-cost", cl::desc("Cost of jump instructions."), cl::init(1), cl::Hidden)
static
cl::opt<unsigned> LoopToColdBlockRatio("loop-to-cold-block-ratio", cl::desc("Outline loop blocks from loop chain if (frequency of loop) / ""(frequency of block) is greater than this ratio"), cl::init(5), cl::Hidden)
static
cl::opt<unsigned> MisfetchCost("misfetch-cost", cl::desc("Cost that models the probabilistic risk of an instruction ""misfetch due to a jump comparing to falling through, whose cost ""is zero."), cl::init(1), cl::Hidden)
static
cl::opt<bool> OutlineOptionalBranches("outline-optional-branches", cl::desc("Outlining optional branches will place blocks that are optional ""branches, i.e. branches with a common post dominator, outside ""the hot path or chain"), cl::init(false), cl::Hidden)
static
cl::opt<unsigned> OutlineOptionalThreshold("outline-optional-threshold", cl::desc("Don't outline optional branches that are a single block with an ""instruction count below this threshold"), cl::init(4), cl::Hidden)
static
block placement

Definition at line 434 of file MachineBlockPlacement.cpp.

block Branch Probability Basic Block Placement

Definition at line 434 of file MachineBlockPlacement.cpp.

cl::opt<bool> PreciseRotationCost("precise-rotation-cost", cl::desc("Model the cost of loop rotation more ""precisely by using profile data."), cl::init(false), cl::Hidden)
static
cl::opt<unsigned> ProfileLikelyProb
cl::opt<unsigned> StaticLikelyProb
void IFOrdering::stats

Definition at line 2113 of file MachineBlockPlacement.cpp.

block placement Basic Block Placement Stats

Definition at line 2113 of file MachineBlockPlacement.cpp.

cl::opt<unsigned> TailDuplicatePlacementThreshold("tail-dup-placement-threshold", cl::desc("Instruction cutoff for tail duplication during layout. ""Tail merging during layout is forced to have a threshold ""that won't conflict."), cl::init(2), cl::Hidden)
static
cl::opt<bool> TailDupPlacement("tail-dup-placement", cl::desc("Perform tail duplication during placement. ""Creates more fallthrough opportunites in ""outline branches."), cl::init(true), cl::Hidden)
static