41 std::vector<std::pair<MachineInstr *, unsigned>> UndefReads;
81 bool pickBestRegisterForUndef(
MachineInstr *MI,
unsigned OpIdx,
86 bool shouldBreakDependence(
MachineInstr *,
unsigned OpIdx,
unsigned Pref);
98 #define DEBUG_TYPE "break-false-deps" 107 bool BreakFalseDeps::pickBestRegisterForUndef(
MachineInstr *
MI,
unsigned OpIdx,
116 unsigned NumRoots = 0;
131 if (!CurrMO.isReg() || CurrMO.isDef() || CurrMO.isUndef() ||
136 MO.
setReg(CurrMO.getReg());
142 unsigned MaxClearance = 0;
143 unsigned MaxClearanceReg = OriginalReg;
147 if (Clearance <= MaxClearance)
149 MaxClearance = Clearance;
150 MaxClearanceReg =
Reg;
152 if (MaxClearance > Pref)
157 if (MaxClearanceReg != OriginalReg)
158 MO.
setReg(MaxClearanceReg);
163 bool BreakFalseDeps::shouldBreakDependence(
MachineInstr *MI,
unsigned OpIdx,
167 LLVM_DEBUG(
dbgs() <<
"Clearance: " << Clearance <<
", want " << Pref);
169 if (Pref > Clearance) {
185 bool HadTrueDependency = pickBestRegisterForUndef(MI, OpNum, Pref);
189 if (!HadTrueDependency && shouldBreakDependence(MI, OpNum, Pref))
190 UndefReads.push_back(std::make_pair(MI, OpNum));
209 if (Pref && shouldBreakDependence(MI, i, Pref))
215 if (UndefReads.empty())
230 unsigned OpIdx = UndefReads.back().second;
240 UndefReads.pop_back();
241 if (UndefReads.empty())
244 UndefMI = UndefReads.back().first;
245 OpIdx = UndefReads.back().second;
260 processUndefReads(MBB);
269 RDA = &getAnalysis<ReachingDefAnalysis>();
273 LLVM_DEBUG(
dbgs() <<
"********** BREAK FALSE DEPENDENCIES **********\n");
277 processBasicBlock(&MBB);
ArrayRef< MCPhysReg > getOrder(const TargetRegisterClass *RC) const
getOrder - Returns the preferred allocation order for RC.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
bool contains(unsigned Reg) const
Return true if the specified register is included in this register class.
This class represents lattice values for constants.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
Describe properties that are true of each instruction in the target description file.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
iterator_range< mop_iterator > operands()
This class provides the reaching def analysis.
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
virtual unsigned getPartialRegUpdateClearance(const MachineInstr &MI, unsigned OpNum, const TargetRegisterInfo *TRI) const
Returns the preferred minimum clearance before an instruction with an unwanted partial register updat...
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
unsigned getNumOperands() const
Retuns the total number of operands.
virtual const TargetRegisterClass * getRegClass(const MCInstrDesc &MCID, unsigned OpNum, const TargetRegisterInfo *TRI, const MachineFunction &MF) const
Given a machine instruction descriptor, returns the register class constraint for OpNum...
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
MCRegUnitRootIterator enumerates the root registers of a register unit.
LaneBitmask contains(unsigned Reg) const
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
void setReg(Register Reg)
Change the register this operand corresponds to.
virtual const TargetInstrInfo * getInstrInfo() const
reverse_iterator rbegin()
void initializeBreakFalseDepsPass(PassRegistry &)
TargetInstrInfo - Interface to description of machine instruction set.
void init(const MachineRegisterInfo &MRI)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
FunctionPass * createBreakFalseDeps()
Creates Break False Dependencies pass.
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
void runOnMachineFunction(const MachineFunction &MF)
runOnFunction - Prepare to answer questions about MF.
A set of live virtual registers and physical register units.
MachineFunctionProperties getRequiredProperties() const override
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
This file implements the LivePhysRegs utility for tracking liveness of physical registers.
bool isDebugInstr() const
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
MachineOperand class - Representation of each machine instruction operand.
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
unsigned getNumDefs() const
Return the number of MachineOperands that are register definitions.
bool isVariadic(QueryType Type=IgnoreBundle) const
Return true if this instruction can have a variable number of operands.
const Function & getFunction() const
Return the LLVM function that this machine code represents.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool isValid() const
isValid - returns true if this iterator is not yet at the end.
void setPreservesAll()
Set by analyses that do not transform their input at all.
MachineFunctionProperties & set(Property P)
Representation of each machine instruction.
virtual void breakPartialRegDependency(MachineInstr &MI, unsigned OpNum, const TargetRegisterInfo *TRI) const
Insert a dependency-breaking instruction before MI to eliminate an unwanted dependency on OpNum...
A set of physical registers with utility functions to track liveness when walking backward/forward th...
int getClearance(MachineInstr *MI, MCPhysReg PhysReg)
Provides the clearance - the number of instructions since the closest reaching def instuction of Phys...
bool hasMinSize() const
Optimize this function for minimum size (-Oz).
bool isReg() const
isReg - Tests if this is a MO_Register operand.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool skipFunction(const Function &F) const
Optional passes call this function to check whether the pass should be skipped.
bool isValid() const
Check if the iterator is at the end of the list.
Register getReg() const
getReg - Returns the register number.
const MachineOperand & getOperand(unsigned i) const
Properties which a MachineFunction may have at a given point in time.
Wrapper class representing virtual and physical registers.
virtual unsigned getUndefRegClearance(const MachineInstr &MI, unsigned &OpNum, const TargetRegisterInfo *TRI) const
Return the minimum clearance before an instruction that reads an unused register. ...