LLVM 24.0.0git
MachineLICM.cpp File Reference
#include "llvm/CodeGen/MachineLICM.h"
#include "CodeGenOptions.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/CodeGen/LazyMachineBlockFrequencyInfo.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineBlockFrequencyInfo.h"
#include "llvm/CodeGen/MachineDomTreeUpdater.h"
#include "llvm/CodeGen/MachineDominators.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineLoopInfo.h"
#include "llvm/CodeGen/MachineMemOperand.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/PseudoSourceValue.h"
#include "llvm/CodeGen/RegisterClassInfo.h"
#include "llvm/CodeGen/TargetInstrInfo.h"
#include "llvm/CodeGen/TargetLowering.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/CodeGen/TargetSchedule.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/IR/Module.h"
#include "llvm/InitializePasses.h"
#include "llvm/MC/MCInstrDesc.h"
#include "llvm/MC/MCRegister.h"
#include "llvm/Pass.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
#include <cassert>
#include <limits>
#include <vector>

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "machinelicm"
#define GET_RESULT(RESULT, GETTER, INFIX)

Enumerations

enum class  UseBFI { None , PGO , All }

Functions

 STATISTIC (NumHoisted, "Number of machine instructions hoisted out of loops")
 STATISTIC (NumLowRP, "Number of instructions hoisted in low reg pressure situation")
 STATISTIC (NumHighLatency, "Number of high latency instructions hoisted")
 STATISTIC (NumCSEed, "Number of hoisted machine instructions CSEed")
 STATISTIC (NumPostRAHoisted, "Number of machine instructions hoisted out of loops post regalloc")
 STATISTIC (NumStoreConst, "Number of stores of const phys reg hoisted out of loops")
 STATISTIC (NumNotHoistedDueToHotness, "Number of instructions not hoisted due to block frequency")
 INITIALIZE_PASS_BEGIN (MachineLICM, DEBUG_TYPE, "Machine Loop Invariant Code Motion", false, false) INITIALIZE_PASS_END(MachineLICM
Machine Loop Invariant Code false INITIALIZE_PASS_BEGIN (EarlyMachineLICM, "early-machinelicm", "Early Machine Loop Invariant Code Motion", false, false) INITIALIZE_PASS_END(EarlyMachineLICM
static bool InstructionStoresToFI (const MachineInstr *MI, int FI)
 Return true if instruction stores to the specified frame.
static void applyBitsNotInRegMaskToRegUnitsMask (const TargetRegisterInfo &TRI, BitVector &RUs, const uint32_t *Mask)
static bool mayLoadFromGOTOrConstantPool (MachineInstr &MI)
 Return true if this machine instruction loads from global offset table or constant pool.
static bool isInvariantStore (const MachineInstr &MI, const TargetRegisterInfo *TRI, const MachineRegisterInfo *MRI)
static bool isCopyFeedingInvariantStore (const MachineInstr &MI, const MachineRegisterInfo *MRI, const TargetRegisterInfo *TRI)

Variables

static cl::opt< UseBFI > DisableHoistingToHotterBlocks ("disable-hoisting-to-hotter-blocks", cl::desc("Disable hoisting instructions to" " hotter blocks"), cl::init(UseBFI::PGO), cl::Hidden, cl::values(clEnumValN(UseBFI::None, "none", "disable the feature"), clEnumValN(UseBFI::PGO, "pgo", "enable the feature when using profile data"), clEnumValN(UseBFI::All, "all", "enable the feature with/wo profile data")))
 DEBUG_TYPE
Machine Loop Invariant Code Motion
Machine Loop Invariant Code false
Machine Loop Invariant Code false early machinelicm

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "machinelicm"

Definition at line 63 of file MachineLICM.cpp.

◆ GET_RESULT

#define GET_RESULT ( RESULT,
GETTER,
INFIX )
Value:
((LegacyPass) \
? &LegacyPass->getAnalysis<RESULT##INFIX##WrapperPass>().GETTER() \
: &MFAM->getResult<RESULT##Analysis>(MF))
block Block Frequency Analysis

Definition at line 335 of file MachineLICM.cpp.

Enumeration Type Documentation

◆ UseBFI

enum class UseBFI
strong
Enumerator
None 
PGO 
All 

Definition at line 65 of file MachineLICM.cpp.

Function Documentation

◆ applyBitsNotInRegMaskToRegUnitsMask()

void applyBitsNotInRegMaskToRegUnitsMask ( const TargetRegisterInfo & TRI,
BitVector & RUs,
const uint32_t * Mask )
static

Definition at line 435 of file MachineLICM.cpp.

References llvm::BitVector::set(), and TRI.

◆ INITIALIZE_PASS_BEGIN() [1/2]

Machine Loop Invariant Code false INITIALIZE_PASS_BEGIN ( EarlyMachineLICM ,
"early-machinelicm" ,
"Early Machine Loop Invariant Code Motion" ,
false ,
false  )

◆ INITIALIZE_PASS_BEGIN() [2/2]

INITIALIZE_PASS_BEGIN ( MachineLICM ,
DEBUG_TYPE ,
"Machine Loop Invariant Code Motion" ,
false ,
false  )

◆ InstructionStoresToFI()

bool InstructionStoresToFI ( const MachineInstr * MI,
int FI )
static

Return true if instruction stores to the specified frame.

Definition at line 414 of file MachineLICM.cpp.

References llvm::dyn_cast(), and MI.

◆ isCopyFeedingInvariantStore()

bool isCopyFeedingInvariantStore ( const MachineInstr & MI,
const MachineRegisterInfo * MRI,
const TargetRegisterInfo * TRI )
static

◆ isInvariantStore()

◆ mayLoadFromGOTOrConstantPool()

bool mayLoadFromGOTOrConstantPool ( MachineInstr & MI)
static

Return true if this machine instruction loads from global offset table or constant pool.

Definition at line 976 of file MachineLICM.cpp.

References assert(), and MI.

◆ STATISTIC() [1/7]

STATISTIC ( NumCSEed ,
"Number of hoisted machine instructions CSEed"  )

◆ STATISTIC() [2/7]

STATISTIC ( NumHighLatency ,
"Number of high latency instructions hoisted"  )

◆ STATISTIC() [3/7]

STATISTIC ( NumHoisted ,
"Number of machine instructions hoisted out of loops"  )

◆ STATISTIC() [4/7]

STATISTIC ( NumLowRP ,
"Number of instructions hoisted in low reg pressure situation"  )

◆ STATISTIC() [5/7]

STATISTIC ( NumNotHoistedDueToHotness ,
"Number of instructions not hoisted due to block frequency"  )

◆ STATISTIC() [6/7]

STATISTIC ( NumPostRAHoisted ,
"Number of machine instructions hoisted out of loops post regalloc"  )

◆ STATISTIC() [7/7]

STATISTIC ( NumStoreConst ,
"Number of stores of const phys reg hoisted out of loops"  )

Variable Documentation

◆ DEBUG_TYPE

DEBUG_TYPE

Definition at line 314 of file MachineLICM.cpp.

◆ DisableHoistingToHotterBlocks

cl::opt< UseBFI > DisableHoistingToHotterBlocks("disable-hoisting-to-hotter-blocks", cl::desc("Disable hoisting instructions to" " hotter blocks"), cl::init(UseBFI::PGO), cl::Hidden, cl::values(clEnumValN(UseBFI::None, "none", "disable the feature"), clEnumValN(UseBFI::PGO, "pgo", "enable the feature when using profile data"), clEnumValN(UseBFI::All, "all", "enable the feature with/wo profile data"))) ( "disable-hoisting-to-hotter-blocks" ,
cl::desc("Disable hoisting instructions to" " hotter blocks") ,
cl::init(UseBFI::PGO) ,
cl::Hidden ,
cl::values(clEnumValN(UseBFI::None, "none", "disable the feature"), clEnumValN(UseBFI::PGO, "pgo", "enable the feature when using profile data"), clEnumValN(UseBFI::All, "all", "enable the feature with/wo profile data"))  )
static

◆ false

Machine Loop Invariant Code false early Early Machine Loop Invariant Code false

Definition at line 315 of file MachineLICM.cpp.

◆ machinelicm

Machine Loop Invariant Code false early machinelicm

Definition at line 324 of file MachineLICM.cpp.

◆ Motion

Machine Loop Invariant Code false early Early Machine Loop Invariant Code Motion

Definition at line 315 of file MachineLICM.cpp.