LLVM API Documentation
#include "llvm/CodeGen/Passes.h"#include "llvm/CodeGen/MachineModuleInfo.h"#include "llvm/CodeGen/MachineFunctionPass.h"#include "llvm/CodeGen/MachineJumpTableInfo.h"#include "llvm/CodeGen/RegisterScavenging.h"#include "llvm/Target/TargetInstrInfo.h"#include "llvm/Target/TargetMachine.h"#include "llvm/Target/TargetRegisterInfo.h"#include "llvm/Support/CommandLine.h"#include "llvm/Support/Debug.h"#include "llvm/Support/ErrorHandling.h"#include "llvm/ADT/SmallSet.h"#include "llvm/ADT/Statistic.h"#include "llvm/ADT/STLExtras.h"#include <algorithm>
Go to the source code of this file.
Defines | |
| #define | DEBUG_TYPE "branchfolding" |
Functions | |
| STATISTIC (NumDeadBlocks,"Number of dead blocks removed") | |
| STATISTIC (NumBranchOpts,"Number of branches optimized") | |
| STATISTIC (NumTailMerge,"Number of block tails merged") | |
| FunctionPass * | llvm::createBranchFoldingPass (bool DefaultEnableTailMerge) |
| static unsigned | HashMachineInstr (const MachineInstr *MI) |
| HashMachineInstr - Compute a hash value for MI and its operands. | |
| static unsigned | HashEndOfMBB (const MachineBasicBlock *MBB, unsigned minCommonTailLength) |
| static unsigned | ComputeCommonTailLength (MachineBasicBlock *MBB1, MachineBasicBlock *MBB2, MachineBasicBlock::iterator &I1, MachineBasicBlock::iterator &I2) |
| static unsigned | EstimateRuntime (MachineBasicBlock::iterator I, MachineBasicBlock::iterator E) |
| static void | FixTail (MachineBasicBlock *CurMBB, MachineBasicBlock *SuccBB, const TargetInstrInfo *TII) |
| static bool | MergeCompare (const std::pair< unsigned, MachineBasicBlock * > &p, const std::pair< unsigned, MachineBasicBlock * > &q) |
| static bool | IsBetterFallthrough (MachineBasicBlock *MBB1, MachineBasicBlock *MBB2) |
Variables | |
| static cl::opt< cl::boolOrDefault > | FlagEnableTailMerge ("enable-tail-merge", cl::init(cl::BOU_UNSET), cl::Hidden) |
| static cl::opt< unsigned > | TailMergeThreshold ("tail-merge-threshold", cl::desc("Max number of predecessors to consider tail merging"), cl::init(150), cl::Hidden) |
| #define DEBUG_TYPE "branchfolding" |
Definition at line 19 of file BranchFolding.cpp.
| static unsigned ComputeCommonTailLength | ( | MachineBasicBlock * | MBB1, | |
| MachineBasicBlock * | MBB2, | |||
| MachineBasicBlock::iterator & | I1, | |||
| MachineBasicBlock::iterator & | I2 | |||
| ) | [static] |
ComputeCommonTailLength - Given two machine basic blocks, compute the number of instructions they actually have in common together at their end. Return iterators for the first shared instruction in each block.
Definition at line 327 of file BranchFolding.cpp.
References llvm::MachineBasicBlock::begin(), llvm::MachineBasicBlock::end(), and llvm::TargetInstrInfo::INLINEASM.
| static unsigned EstimateRuntime | ( | MachineBasicBlock::iterator | I, | |
| MachineBasicBlock::iterator | E | |||
| ) | [static] |
EstimateRuntime - Make a rough estimate for how long it will take to run the specified code.
Definition at line 411 of file BranchFolding.cpp.
References llvm::TargetInstrDesc::isCall(), llvm::TargetInstrDesc::mayLoad(), and llvm::TargetInstrDesc::mayStore().
| static void FixTail | ( | MachineBasicBlock * | CurMBB, | |
| MachineBasicBlock * | SuccBB, | |||
| const TargetInstrInfo * | TII | |||
| ) | [static] |
Definition at line 431 of file BranchFolding.cpp.
References llvm::TargetInstrInfo::AnalyzeBranch(), llvm::SmallVectorImpl< T >::empty(), llvm::MachineFunction::end(), llvm::MachineBasicBlock::getParent(), llvm::TargetInstrInfo::InsertBranch(), llvm::next(), llvm::TargetInstrInfo::RemoveBranch(), and llvm::TargetInstrInfo::ReverseBranchCondition().
| static unsigned HashEndOfMBB | ( | const MachineBasicBlock * | MBB, | |
| unsigned | minCommonTailLength | |||
| ) | [static] |
HashEndOfMBB - Hash the last few instructions in the MBB. For blocks with no successors, we hash two instructions, because cross-jumping only saves code when at least two instructions are removed (since a branch must be inserted). For blocks with a successor, one of the two blocks to be tail-merged will end with a branch already, so it gains to cross-jump even for one instruction.
Definition at line 306 of file BranchFolding.cpp.
References llvm::MachineBasicBlock::begin(), llvm::MachineBasicBlock::end(), and HashMachineInstr().
| static unsigned HashMachineInstr | ( | const MachineInstr * | MI | ) | [static] |
HashMachineInstr - Compute a hash value for MI and its operands.
Definition at line 267 of file BranchFolding.cpp.
References llvm::MachineOperand::getImm(), llvm::MachineOperand::getIndex(), llvm::MachineOperand::getMBB(), llvm::MachineBasicBlock::getNumber(), llvm::MachineInstr::getNumOperands(), llvm::MachineOperand::getOffset(), llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), llvm::MachineOperand::getType(), llvm::MachineOperand::MO_ConstantPoolIndex, llvm::MachineOperand::MO_ExternalSymbol, llvm::MachineOperand::MO_FrameIndex, llvm::MachineOperand::MO_GlobalAddress, llvm::MachineOperand::MO_Immediate, llvm::MachineOperand::MO_JumpTableIndex, llvm::MachineOperand::MO_MachineBasicBlock, and llvm::MachineOperand::MO_Register.
Referenced by HashEndOfMBB().
| static bool IsBetterFallthrough | ( | MachineBasicBlock * | MBB1, | |
| MachineBasicBlock * | MBB2 | |||
| ) | [static] |
IsBetterFallthrough - Return true if it would be clearly better to fall-through to MBB1 than to fall through into MBB2. This has to return a strict ordering, returning true for both (MBB1,MBB2) and (MBB2,MBB1) will result in infinite loops.
Definition at line 861 of file BranchFolding.cpp.
References llvm::MachineBasicBlock::empty(), llvm::MachineBasicBlock::end(), llvm::MachineInstr::getDesc(), llvm::TargetInstrDesc::isCall(), and llvm::MachineBasicBlock::isSuccessor().
| static bool MergeCompare | ( | const std::pair< unsigned, MachineBasicBlock * > & | p, | |
| const std::pair< unsigned, MachineBasicBlock * > & | q | |||
| ) | [static] |
| STATISTIC | ( | NumTailMerge | , | |
| "Number of block tails merged" | ||||
| ) |
| STATISTIC | ( | NumBranchOpts | , | |
| "Number of branches optimized" | ||||
| ) |
| STATISTIC | ( | NumDeadBlocks | , | |
| "Number of dead blocks removed" | ||||
| ) |
Definition at line 67 of file BranchFolding.cpp.
cl::opt<cl::boolOrDefault> FlagEnableTailMerge("enable-tail-merge", cl::init(cl::BOU_UNSET), cl::Hidden) [static] |
char ID [static] |
Definition at line 50 of file BranchFolding.cpp.
| std::vector<MergePotentialsElt> MergePotentials |
Definition at line 83 of file BranchFolding.cpp.
Definition at line 63 of file BranchFolding.cpp.
Referenced by llvm::DwarfException::BeginModule(), llvm::X86RegisterInfo::emitCalleeSavedFrameMoves(), llvm::XCoreRegisterInfo::emitPrologue(), llvm::X86RegisterInfo::emitPrologue(), llvm::SPURegisterInfo::emitPrologue(), llvm::PPCRegisterInfo::emitPrologue(), llvm::DwarfWriter::EndFunction(), llvm::X86RegisterInfo::getCalleeSavedRegClasses(), llvm::X86RegisterInfo::getCalleeSavedRegs(), llvm::Dwarf::getMMI(), llvm::X86RegisterInfo::hasFP(), llvm::XCoreRegisterInfo::needsFrameMoves(), llvm::SelectionDAGISel::runOnMachineFunction(), llvm::PEI::runOnMachineFunction(), llvm::DebugLabelFolder::runOnMachineFunction(), and llvm::XCoreInstrInfo::spillCalleeSavedRegisters().
| const TargetRegisterInfo* RegInfo |
Definition at line 88 of file BranchFolding.cpp.
Referenced by llvm::X86InstrInfo::convertToThreeAddress(), llvm::PPCTargetLowering::EmitAtomicBinary(), llvm::PPCTargetLowering::EmitInstrWithCustomInserter(), llvm::PPCTargetLowering::EmitPartwordAtomicBinary(), llvm::X86InstrInfo::getGlobalBaseReg(), llvm::MipsInstrInfo::getGlobalBaseReg(), llvm::AlphaInstrInfo::getGlobalBaseReg(), llvm::AlphaInstrInfo::getGlobalRetAddr(), llvm::SelectionDAGLowering::GetRegistersForValue(), LowerCTPOP(), llvm::SPUTargetLowering::LowerFormalArguments(), llvm::SparcTargetLowering::LowerFormalArguments(), LowerLOAD(), LowerSTORE(), LowerVECTOR_SHUFFLE(), and llvm::SystemZInstrInfo::restoreCalleeSavedRegisters().
Definition at line 89 of file BranchFolding.cpp.
| std::vector<SameTailElt> SameTails |
Definition at line 86 of file BranchFolding.cpp.
cl::opt<unsigned> TailMergeThreshold("tail-merge-threshold", cl::desc("Max number of predecessors to consider tail merging"), cl::init(150), cl::Hidden) [static] |
| const TargetInstrInfo* TII |
Definition at line 62 of file BranchFolding.cpp.
Referenced by llvm::createBURRListDAGScheduler(), llvm::createTDRRListDAGScheduler(), llvm::PPCTargetLowering::EmitAtomicBinary(), llvm::XCoreTargetLowering::EmitInstrWithCustomInserter(), llvm::SystemZTargetLowering::EmitInstrWithCustomInserter(), llvm::SparcTargetLowering::EmitInstrWithCustomInserter(), llvm::PPCTargetLowering::EmitInstrWithCustomInserter(), llvm::PIC16TargetLowering::EmitInstrWithCustomInserter(), llvm::MSP430TargetLowering::EmitInstrWithCustomInserter(), llvm::ARMTargetLowering::EmitInstrWithCustomInserter(), llvm::AlphaTargetLowering::EmitInstrWithCustomInserter(), llvm::PPCTargetLowering::EmitPartwordAtomicBinary(), llvm::X86InstrInfo::getGlobalBaseReg(), llvm::MipsInstrInfo::getGlobalBaseReg(), llvm::AlphaInstrInfo::getGlobalBaseReg(), llvm::AlphaInstrInfo::getGlobalRetAddr(), GetInstSizeWithDesc(), llvm::SDNode::getOperationName(), llvm::VirtRegMap::runOnMachineFunction(), llvm::SelectionDAGISel::runOnMachineFunction(), llvm::FunctionLoweringInfo::set(), and llvm::SplitCriticalMachineEdge().