36#define DEBUG_TYPE "lrshrink"
39 "Number of insructions hoisted to shrink live range.");
63char LiveRangeShrink::ID = 0;
79 const InstOrderMap &M) {
80 auto NewIter = M.find(&New);
81 if (NewIter == M.end())
85 unsigned OrderOld = M.find(Old)->second;
86 unsigned OrderNew = NewIter->second;
87 if (OrderOld != OrderNew)
88 return OrderOld < OrderNew ? &New : Old;
91 for (
MachineInstr *
I = Old->getNextNode(); M.find(
I)->second == OrderNew;
140 bool SawStore =
false;
142 while (Next !=
MBB.
end()) {
148 unsigned CurrentOrder = IOM[&
MI];
152 if (!MO.isReg() || MO.isDebug())
155 UseMap[MO.getReg()] = std::make_pair(CurrentOrder, &
MI);
156 else if (MO.isDead() && UseMap.
count(MO.getReg()))
159 if (Barrier < UseMap[MO.getReg()].first) {
160 Barrier = UseMap[MO.getReg()].first;
161 BarrierMI = UseMap[MO.getReg()].second;
165 if (!
MI.isSafeToMove(SawStore)) {
169 if (
MI.hasUnmodeledSideEffects() && !
MI.isPseudoProbe() &&
182 unsigned NumEligibleUse = 0;
185 if (!MO.isReg() || MO.isDead() || MO.isDebug())
190 if (!
Reg.isVirtual()) {
191 if (!Reg ||
MRI.isConstantPhysReg(Reg))
203 }
else if (
MRI.hasOneNonDBGUse(Reg) &&
MRI.hasOneDef(Reg) && DefMO &&
205 MRI.getRegClass(MO.getReg())) {
211 if (!
TII.isCopyInstr(DefInstr))
223 I =
I->getNextNode())
224 if (
I == BarrierMI) {
229 if (DefMO && Insert && NumEligibleUse > 1 && Barrier <= IOM[Insert]) {
232 while (
I !=
MBB.
end() && (
I->isPHI() ||
I->isDebugOrPseudoInstr()))
234 if (
I ==
MI.getIterator())
240 unsigned NewOrder = IOM[&*
I];
242 NumInstrsHoistedToShrinkLiveRange++;
246 if (
MI.getOperand(0).isReg())
247 for (; EndIter !=
MBB.
end() && EndIter->isDebugValue() &&
248 EndIter->hasDebugOperandForReg(
MI.getOperand(0).getReg());
250 IOM[&*EndIter] = NewOrder;
unsigned const MachineRegisterInfo * MRI
This file defines the DenseMap class.
const HexagonInstrInfo * TII
static MachineInstr * FindDominatedInstruction(MachineInstr &New, MachineInstr *Old, const InstOrderMap &M)
Returns New if it's dominated by Old, otherwise return Old.
static void BuildInstOrderMap(MachineBasicBlock::iterator Start, InstOrderMap &M)
Builds Instruction to its dominating order number map M by traversing from instruction Start.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
Represent the analysis usage information of a pass.
void setPreservesCFG()
This function should be called by the pass, iff they do not:
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
bool isEHPad() const
Returns true if the block is a landing pad.
iterator SkipPHIsLabelsAndDebug(iterator I, Register Reg=Register(), bool SkipPseudoOp=true)
Return the first instruction in MBB after I that is not a PHI, label or debug.
void splice(iterator Where, MachineBasicBlock *Other, iterator From)
Take an instruction from MBB 'Other' at the position From, and insert it into this MBB right before '...
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
Register getReg() const
getReg - Returns the register number.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
Wrapper class representing virtual and physical registers.
StringRef - Represent a constant reference to a string, i.e.
TargetInstrInfo - Interface to description of machine instruction set.
virtual const TargetInstrInfo * getInstrInfo() const
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Reg
All possible values of the reg field in the ModR/M byte.
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
void initializeLiveRangeShrinkPass(PassRegistry &)
char & LiveRangeShrinkID
LiveRangeShrink pass.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.