42 std::vector<std::pair<MachineInstr *, unsigned>> UndefReads;
82 bool pickBestRegisterForUndef(
MachineInstr *MI,
unsigned OpIdx,
87 bool shouldBreakDependence(
MachineInstr *,
unsigned OpIdx,
unsigned Pref);
99 #define DEBUG_TYPE "break-false-deps" 108 bool BreakFalseDeps::pickBestRegisterForUndef(
MachineInstr *
MI,
unsigned OpIdx,
113 unsigned OriginalReg = MO.
getReg();
117 unsigned NumRoots = 0;
132 if (!CurrMO.isReg() || CurrMO.isDef() || CurrMO.isUndef() ||
137 MO.
setReg(CurrMO.getReg());
143 unsigned MaxClearance = 0;
144 unsigned MaxClearanceReg = OriginalReg;
148 if (Clearance <= MaxClearance)
150 MaxClearance = Clearance;
151 MaxClearanceReg =
Reg;
153 if (MaxClearance > Pref)
158 if (MaxClearanceReg != OriginalReg)
159 MO.
setReg(MaxClearanceReg);
164 bool BreakFalseDeps::shouldBreakDependence(
MachineInstr *MI,
unsigned OpIdx,
168 LLVM_DEBUG(
dbgs() <<
"Clearance: " << Clearance <<
", want " << Pref);
170 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));
204 if (Pref && shouldBreakDependence(MI, i, Pref))
210 if (UndefReads.empty())
220 unsigned OpIdx = UndefReads.back().second;
230 UndefReads.pop_back();
231 if (UndefReads.empty())
234 UndefMI = UndefReads.back().first;
235 OpIdx = UndefReads.back().second;
250 processUndefReads(MBB);
259 RDA = &getAnalysis<ReachingDefAnalysis>();
263 LLVM_DEBUG(
dbgs() <<
"********** BREAK FALSE DEPENDENCIES **********\n");
267 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.
unsigned getReg() const
getReg - Returns the register number.
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.
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
virtual const TargetInstrInfo * getInstrInfo() const
reverse_iterator rbegin()
void initializeBreakFalseDepsPass(PassRegistry &)
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
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.
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...
void setReg(unsigned Reg)
Change the register this operand corresponds to.
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.
const MachineOperand & getOperand(unsigned i) const
Properties which a MachineFunction may have at a given point in time.
virtual unsigned getUndefRegClearance(const MachineInstr &MI, unsigned &OpNum, const TargetRegisterInfo *TRI) const
Return the minimum clearance before an instruction that reads an unused register. ...