44 std::vector<std::pair<MachineInstr *, unsigned>> UndefReads;
89 bool shouldBreakDependence(
MachineInstr *,
unsigned OpIdx,
unsigned Pref);
101#define DEBUG_TYPE "break-false-deps"
110bool BreakFalseDeps::pickBestRegisterForUndef(
MachineInstr *
MI,
unsigned OpIdx,
114 if (
MI->isRegTiedToDefOperand(OpIdx))
128 unsigned NumRoots = 0;
139 assert(OpRC &&
"Not a valid register class");
144 if (CurrMO.isUndef() || !OpRC->
contains(CurrMO.getReg()))
148 MO.
setReg(CurrMO.getReg());
154 unsigned MaxClearance = 0;
155 unsigned MaxClearanceReg = OriginalReg;
159 if (Clearance <= MaxClearance)
161 MaxClearance = Clearance;
162 MaxClearanceReg =
Reg;
164 if (MaxClearance > Pref)
169 if (MaxClearanceReg != OriginalReg)
170 MO.
setReg(MaxClearanceReg);
175bool BreakFalseDeps::shouldBreakDependence(
MachineInstr *
MI,
unsigned OpIdx,
179 LLVM_DEBUG(
dbgs() <<
"Clearance: " << Clearance <<
", want " << Pref);
181 if (Pref > Clearance) {
190 assert(!
MI->isDebugInstr() &&
"Won't process debug values");
203 bool HadTrueDependency = pickBestRegisterForUndef(
MI, i, Pref);
207 if (!HadTrueDependency && shouldBreakDependence(
MI, i, Pref))
208 UndefReads.push_back(std::make_pair(
MI, i));
227 if (Pref && shouldBreakDependence(
MI, i, Pref))
233 if (UndefReads.empty())
248 unsigned OpIdx = UndefReads.back().second;
258 UndefReads.pop_back();
259 if (UndefReads.empty())
262 UndefMI = UndefReads.back().first;
263 OpIdx = UndefReads.back().second;
275 if (!
MI.isDebugInstr())
278 processUndefReads(
MBB);
287 RDA = &getAnalysis<ReachingDefAnalysis>();
291 LLVM_DEBUG(
dbgs() <<
"********** BREAK FALSE DEPENDENCIES **********\n");
302 processBasicBlock(&
MBB);
This file builds on the ADT/GraphTraits.h file to build generic depth first graph iterator.
This file implements the LivePhysRegs utility for tracking liveness of physical registers.
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
void setPreservesAll()
Set by analyses that do not transform their input at all.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
MachineFunctionProperties getRequiredProperties() const override
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
FunctionPass class - This class is used to implement most global optimizations.
bool skipFunction(const Function &F) const
Optional passes call this function to check whether the pass should be skipped.
bool hasMinSize() const
Optimize this function for minimum size (-Oz).
A set of physical registers with utility functions to track liveness when walking backward/forward th...
A set of live virtual registers and physical register units.
LaneBitmask contains(Register Reg) const
void init(const MachineRegisterInfo &MRI)
Describe properties that are true of each instruction in the target description file.
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
unsigned getNumDefs() const
Return the number of MachineOperands that are register definitions.
MCRegUnitRootIterator enumerates the root registers of a register unit.
bool isValid() const
Check if the iterator is at the end of the list.
iterator_range< MCRegUnitIterator > regunits(MCRegister Reg) const
Returns an iterator range over all regunits for Reg.
Wrapper class representing physical registers. Should be passed by value.
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.
Properties which a MachineFunction may have at a given point in time.
MachineFunctionProperties & set(Property P)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Function & getFunction()
Return the LLVM function that this machine code represents.
Representation of each machine instruction.
const MachineOperand & getOperand(unsigned i) const
MachineOperand class - Representation of each machine instruction operand.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
void setReg(Register Reg)
Change the register this operand corresponds to.
bool isRenamable() const
isRenamable - Returns true if this register may be renamed, i.e.
Register getReg() const
getReg - Returns the register number.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
This class provides the reaching def analysis.
int getClearance(MachineInstr *MI, MCRegister PhysReg) const
Provides the clearance - the number of instructions since the closest reaching def instuction of Phys...
void runOnMachineFunction(const MachineFunction &MF)
runOnFunction - Prepare to answer questions about MF.
ArrayRef< MCPhysReg > getOrder(const TargetRegisterClass *RC) const
getOrder - Returns the preferred allocation order for RC.
MCRegister asMCReg() const
Utility to check-convert this value to a MCRegister.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
TargetInstrInfo - Interface to description of machine instruction set.
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...
virtual unsigned getUndefRegClearance(const MachineInstr &MI, unsigned OpNum, const TargetRegisterInfo *TRI) const
Return the minimum clearance before an instruction that reads an unused register.
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.
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,...
bool contains(Register Reg) const
Return true if the specified register is included in this register class.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
virtual const TargetInstrInfo * getInstrInfo() const
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< df_ext_iterator< T, SetTy > > depth_first_ext(const T &G, SetTy &S)
auto reverse(ContainerTy &&C)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void initializeBreakFalseDepsPass(PassRegistry &)
FunctionPass * createBreakFalseDeps()
Creates Break False Dependencies pass.