41 #define DEBUG_TYPE "regalloc" 47 struct CompSpillWeight {
67 std::unique_ptr<Spiller> SpillerInstance;
68 std::priority_queue<LiveInterval*, std::vector<LiveInterval*>,
69 CompSpillWeight> Queue;
75 bool LRE_CanEraseVirtReg(
unsigned)
override;
76 void LRE_WillShrinkVirtReg(
unsigned)
override;
82 StringRef getPassName()
const override {
return "Basic Register Allocator"; }
87 void releaseMemory()
override;
89 Spiller &spiller()
override {
return *SpillerInstance; }
117 bool spillInterferences(
LiveInterval &VirtReg,
unsigned PhysReg,
144 bool RABasic::LRE_CanEraseVirtReg(
unsigned VirtReg) {
146 if (VRM->hasPhys(VirtReg)) {
148 aboutToRemoveInterval(LI);
159 void RABasic::LRE_WillShrinkVirtReg(
unsigned VirtReg) {
160 if (!VRM->hasPhys(VirtReg))
196 void RABasic::releaseMemory() {
197 SpillerInstance.reset();
204 bool RABasic::spillInterferences(
LiveInterval &VirtReg,
unsigned PhysReg,
222 <<
" interferences with " << VirtReg <<
"\n");
226 for (
unsigned i = 0,
e = Intfs.
size(); i !=
e; ++i) {
230 if (!VRM->hasPhys(Spill.
reg))
238 LiveRangeEdit LRE(&Spill, SplitVRegs, *MF, *LIS, VRM,
this, &DeadRemats);
239 spiller().spill(LRE);
263 while (
unsigned PhysReg = Order.
next()) {
265 switch (
Matrix->checkInterference(VirtReg, PhysReg)) {
283 PhysRegE = PhysRegSpillCands.
end(); PhysRegI != PhysRegE; ++PhysRegI) {
284 if (!spillInterferences(VirtReg, *PhysRegI, SplitVRegs))
287 assert(!
Matrix->checkInterference(VirtReg, *PhysRegI) &&
288 "Interference after spill.");
297 LiveRangeEdit LRE(&VirtReg, SplitVRegs, *MF, *LIS, VRM,
this, &DeadRemats);
298 spiller().spill(LRE);
306 LLVM_DEBUG(
dbgs() <<
"********** BASIC REGISTER ALLOCATION **********\n" 307 <<
"********** Function: " << mf.
getName() <<
'\n');
311 getAnalysis<LiveIntervals>(),
312 getAnalysis<LiveRegMatrix>());
315 getAnalysis<MachineLoopInfo>(),
316 getAnalysis<MachineBlockFrequencyInfo>());
332 return new RABasic();
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
No interference, go ahead and assign.
This class represents lattice values for constants.
static RegisterRegAlloc basicRegAlloc("basic", "basic register allocator", createBasicRegisterAllocator)
void push_back(const T &Elt)
char & MachineDominatorsID
MachineDominators - This pass is a machine dominators analysis pass.
LiveInterval - This class represents the liveness of a register, or stack slot.
MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate machine basic b...
unsigned next(unsigned Limit=0)
Return the next physical register in the allocation order, or 0.
unsigned const TargetRegisterInfo * TRI
Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
Callback methods for LiveRangeEdit owners.
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
Query interferences between a single live virtual register and a live interval union.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
INITIALIZE_PASS_BEGIN(RABasic, "regallocbasic", "Basic Register Allocator", false, false) INITIALIZE_PASS_END(RABasic
RegAllocBase provides the register allocation driver and interface that can be extended to add intere...
const SmallVectorImpl< LiveInterval * > & interferingVRegs() const
AnalysisUsage & addPreservedID(const void *ID)
char & RABasicID
Basic register allocator.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
unsigned collectInterferingVRegs(unsigned MaxInterferingRegs=std::numeric_limits< unsigned >::max())
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
void init(VirtRegMap &vrm, LiveIntervals &lis, LiveRegMatrix &mat)
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
void calculateSpillWeightsAndHints(LiveIntervals &LIS, MachineFunction &MF, VirtRegMap *VRM, const MachineLoopInfo &MLI, const MachineBlockFrequencyInfo &MBFI, VirtRegAuxInfo::NormalizingFn norm=normalizeSpillWeight)
Compute spill weights and allocation hints for all virtual register live intervals.
AnalysisUsage & addRequiredID(const void *ID)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
FunctionPass * createBasicRegisterAllocator()
BasicRegisterAllocation Pass - This pass implements a degenerate global register allocator using the ...
void setPreservesCFG()
This function should be called by the pass, iff they do not:
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.
MachineFunctionProperties & set(Property P)
Spiller * createInlineSpiller(MachineFunctionPass &pass, MachineFunction &mf, VirtRegMap &vrm)
Create and return a spiller that will insert spill code directly instead of deferring though VirtRegM...
LLVM_NODISCARD bool empty() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool isSpillable() const
isSpillable - Can this interval be spilled?
StringRef - Represent a constant reference to a string, i.e.
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object...
Virtual register interference.
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
Properties which a MachineFunction may have at a given point in time.
Wrapper class representing virtual and physical registers.