39#define DEBUG_TYPE "regalloc"
45 struct CompSpillWeight {
47 return A->weight() <
B->weight();
65 std::unique_ptr<Spiller> SpillerInstance;
66 std::priority_queue<const LiveInterval *, std::vector<const LiveInterval *>,
108 MachineFunctionProperties::Property::NoPHIs);
113 MachineFunctionProperties::Property::IsSSA);
148bool RABasic::LRE_CanEraseVirtReg(
Register VirtReg) {
150 if (VRM->hasPhys(VirtReg)) {
152 aboutToRemoveInterval(LI);
163void RABasic::LRE_WillShrinkVirtReg(
Register VirtReg) {
164 if (!VRM->hasPhys(VirtReg))
201void RABasic::releaseMemory() {
202 SpillerInstance.reset();
209bool RABasic::spillInterferences(
const LiveInterval &VirtReg,
220 if (!Intf->isSpillable() || Intf->weight() > VirtReg.
weight())
226 <<
" interferences with " << VirtReg <<
"\n");
232 if (!VRM->hasPhys(
Spill->reg()))
240 LiveRangeEdit LRE(Spill, SplitVRegs, *MF, *LIS, VRM,
this, &DeadRemats);
241 spiller().spill(LRE);
269 switch (
Matrix->checkInterference(VirtReg, PhysReg)) {
286 for (
MCRegister &PhysReg : PhysRegSpillCands) {
287 if (!spillInterferences(VirtReg, PhysReg, SplitVRegs))
291 "Interference after spill.");
300 LiveRangeEdit LRE(&VirtReg, SplitVRegs, *MF, *LIS, VRM,
this, &DeadRemats);
301 spiller().spill(LRE);
309 LLVM_DEBUG(
dbgs() <<
"********** BASIC REGISTER ALLOCATION **********\n"
310 <<
"********** Function: " << mf.
getName() <<
'\n');
314 getAnalysis<LiveIntervalsWrapperPass>().getLIS(),
315 getAnalysis<LiveRegMatrixWrapperLegacy>().getLRM());
317 *MF, *LIS, *VRM, getAnalysis<MachineLoopInfoWrapperPass>().getLI(),
318 getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI(),
319 &getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI());
320 VRAI.calculateSpillWeightsAndHints();
335 return new RABasic();
339 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...
An analysis pass based on legacy pass manager to deliver ProfileSummaryInfo.
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.