42 #define DEBUG_TYPE "regalloc" 48 struct CompSpillWeight {
68 std::unique_ptr<Spiller> SpillerInstance;
69 std::priority_queue<LiveInterval*, std::vector<LiveInterval*>,
70 CompSpillWeight> Queue;
76 bool LRE_CanEraseVirtReg(
unsigned)
override;
77 void LRE_WillShrinkVirtReg(
unsigned)
override;
83 StringRef getPassName()
const override {
return "Basic Register Allocator"; }
88 void releaseMemory()
override;
90 Spiller &spiller()
override {
return *SpillerInstance; }
118 bool spillInterferences(
LiveInterval &VirtReg,
unsigned PhysReg,
145 bool RABasic::LRE_CanEraseVirtReg(
unsigned VirtReg) {
147 if (VRM->hasPhys(VirtReg)) {
149 aboutToRemoveInterval(LI);
160 void RABasic::LRE_WillShrinkVirtReg(
unsigned VirtReg) {
161 if (!VRM->hasPhys(VirtReg))
197 void RABasic::releaseMemory() {
198 SpillerInstance.reset();
205 bool RABasic::spillInterferences(
LiveInterval &VirtReg,
unsigned PhysReg,
223 <<
" interferences with " << VirtReg <<
"\n");
227 for (
unsigned i = 0, e = Intfs.
size(); i != e; ++i) {
231 if (!VRM->hasPhys(Spill.
reg))
239 LiveRangeEdit LRE(&Spill, SplitVRegs, *MF, *LIS, VRM,
this, &DeadRemats);
240 spiller().spill(LRE);
264 while (
unsigned PhysReg = Order.
next()) {
266 switch (
Matrix->checkInterference(VirtReg, PhysReg)) {
284 PhysRegE = PhysRegSpillCands.
end(); PhysRegI != PhysRegE; ++PhysRegI) {
285 if (!spillInterferences(VirtReg, *PhysRegI, SplitVRegs))
288 assert(!
Matrix->checkInterference(VirtReg, *PhysRegI) &&
289 "Interference after spill.");
298 LiveRangeEdit LRE(&VirtReg, SplitVRegs, *MF, *LIS, VRM,
this, &DeadRemats);
299 spiller().spill(LRE);
307 LLVM_DEBUG(
dbgs() <<
"********** BASIC REGISTER ALLOCATION **********\n" 308 <<
"********** Function: " << mf.
getName() <<
'\n');
312 getAnalysis<LiveIntervals>(),
313 getAnalysis<LiveRegMatrix>());
316 getAnalysis<MachineLoopInfo>(),
317 getAnalysis<MachineBlockFrequencyInfo>());
333 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
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...
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.
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)
RegisterRegAlloc class - Track the registration of register allocators.
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.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
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 ...
Promote Memory to Register
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_ATTRIBUTE_ALWAYS_INLINE iterator end()
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.