38#define DEBUG_TYPE "regalloc"
44 struct CompSpillWeight {
46 return A->weight() <
B->weight();
64 std::unique_ptr<Spiller> SpillerInstance;
65 std::priority_queue<const LiveInterval *, std::vector<const LiveInterval *>,
107 MachineFunctionProperties::Property::NoPHIs);
112 MachineFunctionProperties::Property::IsSSA);
146bool RABasic::LRE_CanEraseVirtReg(
Register VirtReg) {
148 if (VRM->hasPhys(VirtReg)) {
150 aboutToRemoveInterval(LI);
161void RABasic::LRE_WillShrinkVirtReg(
Register VirtReg) {
162 if (!VRM->hasPhys(VirtReg))
198void RABasic::releaseMemory() {
199 SpillerInstance.reset();
206bool RABasic::spillInterferences(
const LiveInterval &VirtReg,
217 if (!Intf->isSpillable() || Intf->weight() > VirtReg.
weight())
223 <<
" interferences with " << VirtReg <<
"\n");
229 if (!VRM->hasPhys(
Spill->reg()))
237 LiveRangeEdit LRE(Spill, SplitVRegs, *MF, *LIS, VRM,
this, &DeadRemats);
238 spiller().spill(LRE);
266 switch (
Matrix->checkInterference(VirtReg, PhysReg)) {
283 for (
MCRegister &PhysReg : PhysRegSpillCands) {
284 if (!spillInterferences(VirtReg, PhysReg, SplitVRegs))
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<LiveIntervalsWrapperPass>().getLIS(),
312 getAnalysis<LiveRegMatrix>());
314 *MF, *LIS, *VRM, getAnalysis<MachineLoopInfoWrapperPass>().getLI(),
315 getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI());
316 VRAI.calculateSpillWeightsAndHints();
331 return new RABasic();
335 return new RABasic(
F);
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
unsigned const TargetRegisterInfo * TRI
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
static RegisterRegAlloc basicRegAlloc("basic", "basic register allocator", createBasicRegisterAllocator)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object.
static AllocationOrder create(unsigned VirtReg, const VirtRegMap &VRM, const RegisterClassInfo &RegClassInfo, const LiveRegMatrix *Matrix)
Create a new AllocationOrder for VirtReg.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequiredID(const void *ID)
AnalysisUsage & addPreservedID(const void *ID)
AnalysisUsage & addRequired()
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
void setPreservesCFG()
This function should be called by the pass, iff they do not:
FunctionPass class - This class is used to implement most global optimizations.
Query interferences between a single live virtual register and a live interval union.
const SmallVectorImpl< const LiveInterval * > & interferingVRegs(unsigned MaxInterferingRegs=std::numeric_limits< unsigned >::max())
LiveInterval - This class represents the liveness of a register, or stack slot.
bool isSpillable() const
isSpillable - Can this interval be spilled?
Callback methods for LiveRangeEdit owners.
virtual bool LRE_CanEraseVirtReg(Register)
Called when a virtual register is no longer used.
virtual void LRE_WillShrinkVirtReg(Register)
Called before shrinking the live range of a virtual register.
@ IK_VirtReg
Virtual register interference.
@ IK_Free
No interference, go ahead and assign.
Wrapper class representing physical registers. Should be passed by value.
constexpr bool isValid() const
Analysis pass which computes a MachineDominatorTree.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
virtual MachineFunctionProperties getClearedProperties() const
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
virtual MachineFunctionProperties getRequiredProperties() const
Properties which a MachineFunction may have at a given point in time.
MachineFunctionProperties & set(Property P)
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
virtual void releaseMemory()
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
RegAllocBase provides the register allocation driver and interface that can be extended to add intere...
virtual MCRegister selectOrSplit(const LiveInterval &VirtReg, SmallVectorImpl< Register > &splitLVRs)=0
void init(VirtRegMap &vrm, LiveIntervals &lis, LiveRegMatrix &mat)
virtual Spiller & spiller()=0
virtual const LiveInterval * dequeue()=0
dequeue - Return the next unassigned register, or NULL.
virtual void enqueueImpl(const LiveInterval *LI)=0
enqueue - Add VirtReg to the priority queue of unassigned registers.
Wrapper class representing virtual and physical registers.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Calculate auxiliary information for a virtual register such as its spill weight and allocation hint.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
std::function< bool(const TargetRegisterInfo &TRI, const MachineRegisterInfo &MRI, const Register Reg)> RegAllocFilterFunc
Filter function for register classes during regalloc.
char & MachineDominatorsID
MachineDominators - This pass is a machine dominators analysis pass.
Spiller * createInlineSpiller(MachineFunctionPass &Pass, MachineFunction &MF, VirtRegMap &VRM, VirtRegAuxInfo &VRAI)
Create and return a spiller that will insert spill code directly instead of deferring though VirtRegM...
auto reverse(ContainerTy &&C)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
FunctionPass * createBasicRegisterAllocator()
BasicRegisterAllocation Pass - This pass implements a degenerate global register allocator using the ...
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.
char & RABasicID
Basic register allocator.