16 #define DEBUG_TYPE "reaching-deps-analysis" 27 assert(MBBNumber < MBBReachingDefs.size() &&
28 "Unexpected basic block number.");
29 MBBReachingDefs[MBBNumber].resize(NumRegUnits);
37 LiveRegs.assign(NumRegUnits, ReachingDefDefaultVal);
41 for (
const auto &LI : MBB->
liveins()) {
47 MBBReachingDefs[MBBNumber][*
Unit].push_back(LiveRegs[*
Unit]);
56 assert(
unsigned(
pred->getNumber()) < MBBOutRegsInfos.size() &&
57 "Should have pre-allocated MBBInfos for all MBBs");
58 const LiveRegsDefInfo &Incoming = MBBOutRegsInfos[
pred->getNumber()];
67 if ((LiveRegs[Unit] != ReachingDefDefaultVal))
68 MBBReachingDefs[MBBNumber][
Unit].push_back(LiveRegs[Unit]);
73 << (!TraversedMBB.IsDone ?
": incomplete\n" 74 :
": all preds known\n"));
77 void ReachingDefAnalysis::leaveBasicBlock(
79 assert(!LiveRegs.empty() &&
"Must enter basic block first.");
82 "Unexpected basic block number.");
84 MBBOutRegsInfos[MBBNumber] = LiveRegs;
90 for (
int &OutLiveReg : MBBOutRegsInfos[MBBNumber])
91 OutLiveReg -= CurInstr;
100 "Unexpected basic block number.");
116 LiveRegs[*
Unit] = CurInstr;
120 InstIds[
MI] = CurInstr;
124 void ReachingDefAnalysis::processBasicBlock(
126 enterBasicBlock(TraversedMBB);
131 leaveBasicBlock(TraversedMBB);
145 LLVM_DEBUG(
dbgs() <<
"********** REACHING DEFINITION ANALYSIS **********\n");
154 processBasicBlock(TraversedMBB);
158 for (MBBDefsInfo &MBBDefs : MBBReachingDefs) {
168 MBBOutRegsInfos.
clear();
169 MBBReachingDefs.
clear();
174 assert(InstIds.count(MI) &&
"Unexpected machine instuction.");
175 int InstId = InstIds[
MI];
176 int DefRes = ReachingDefDefaultVal;
179 "Unexpected basic block number.");
180 int LatestDef = ReachingDefDefaultVal;
182 for (
int Def : MBBReachingDefs[MBBNumber][*
Unit]) {
187 LatestDef =
std::max(LatestDef, DefRes);
193 assert(InstIds.count(MI) &&
"Unexpected machine instuction.");
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
This class represents lattice values for constants.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
unsigned getNumBlockIDs() const
getNumBlockIDs - Return the number of MBB ID's allocated.
void push_back(const T &Elt)
Describe properties that are true of each instruction in the target description file.
unsigned getReg() const
getReg - Returns the register number.
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
unsigned const TargetRegisterInfo * TRI
unsigned getNumRegUnits() const
Return the number of (native) register units in the target.
INITIALIZE_PASS(ReachingDefAnalysis, DEBUG_TYPE, "ReachingDefAnalysis", false, true) void ReachingDefAnalysis
This class provides the reaching def analysis.
Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
unsigned getNumOperands() const
Retuns the total number of operands.
Printable printReg(unsigned Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
iterator_range< pred_iterator > predecessors()
bool isDebugInstr() const
void sort(IteratorTy Start, IteratorTy End)
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
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.
const MachineBasicBlock * getParent() const
Representation of each machine instruction.
int getClearance(MachineInstr *MI, MCPhysReg PhysReg)
Provides the clearance - the number of instructions since the closest reaching def instuction of Phys...
TraversalOrder traverse(MachineFunction &MF)
This class provides the basic blocks traversal order used by passes like ReachingDefAnalysis and Exec...
iterator_range< livein_iterator > liveins() const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
int getReachingDef(MachineInstr *MI, int PhysReg)
Provides the instruction id of the closest reaching def instruction of PhysReg that reaches MI...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MachineBasicBlock * MBB
The basic block.
bool skipFunction(const Function &F) const
Optional passes call this function to check whether the pass should be skipped.
const MachineOperand & getOperand(unsigned i) const