36#define DEBUG_TYPE "regalloc"
64 if (VRM->hasPhys(VirtReg)) {
66 aboutToRemoveInterval(LI);
77void RABasic::LRE_WillShrinkVirtReg(
Register VirtReg) {
117 SpillerInstance.reset();
135 if (!Intf->isSpillable() || Intf->weight() > VirtReg.
weight())
141 <<
" interferences with " << VirtReg <<
"\n");
182 assert(PhysReg.isValid());
201 for (
MCRegister &PhysReg : PhysRegSpillCands) {
206 "Interference after spill.");
224 LLVM_DEBUG(
dbgs() <<
"********** BASIC REGISTER ALLOCATION **********\n"
225 <<
"********** Function: " << mf.
getName() <<
'\n');
228 auto &MBFI = getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI();
229 auto &LiveStks = getAnalysis<LiveStacksWrapperLegacy>().getLS();
230 auto &MDT = getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree();
233 getAnalysis<LiveIntervalsWrapperPass>().getLIS(),
234 getAnalysis<LiveRegMatrixWrapperLegacy>().getLRM());
236 getAnalysis<MachineLoopInfoWrapperPass>().getLI(), MBFI,
237 &getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI());
240 SpillerInstance.reset(
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#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)
This file declares the RABasic class, which provides a minimal implementation of the basic register a...
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object.
static AllocationOrder create(Register VirtReg, const VirtRegMap &VRM, const RegisterClassInfo &RegClassInfo, const LiveRegMatrix *Matrix)
Create a new AllocationOrder for VirtReg.
Represent the analysis usage information of a pass.
LLVM_ABI 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.
LLVM_ABI 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?
LiveInterval & getInterval(Register Reg)
void unassign(const LiveInterval &VirtReg)
Unassign VirtReg from its PhysReg.
LiveIntervalUnion::Query & query(const LiveRange &LR, MCRegUnit RegUnit)
Query a line of the assigned virtual register matrix directly.
@ IK_VirtReg
Virtual register interference.
@ IK_Free
No interference, go ahead and assign.
InterferenceKind checkInterference(const LiveInterval &VirtReg, MCRegister PhysReg)
Check for interference before assigning VirtReg to PhysReg.
iterator_range< MCRegUnitIterator > regunits(MCRegister Reg) const
Returns an iterator range over all regunits for Reg.
Wrapper class representing physical registers. Should be passed by value.
Analysis pass which computes a MachineDominatorTree.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
An analysis pass based on legacy pass manager to deliver ProfileSummaryInfo.
RABasic provides a minimal implementation of the basic register allocation algorithm.
void getAnalysisUsage(AnalysisUsage &AU) const override
RABasic analysis usage.
MCRegister selectOrSplit(const LiveInterval &VirtReg, SmallVectorImpl< Register > &SplitVRegs) override
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
Spiller & spiller() override
RABasic(const RegAllocFilterFunc F=nullptr)
bool runOnMachineFunction(MachineFunction &mf) override
Perform register allocation.
bool spillInterferences(const LiveInterval &VirtReg, MCRegister PhysReg, SmallVectorImpl< Register > &SplitVRegs)
RegAllocBase provides the register allocation driver and interface that can be extended to add intere...
void enqueue(const LiveInterval *LI)
enqueue - Add VirtReg to the priority queue of unassigned registers.
void init(VirtRegMap &vrm, LiveIntervals &lis, LiveRegMatrix &mat)
SmallPtrSet< MachineInstr *, 32 > DeadRemats
Inst which is a def of an original reg and whose defs are already all dead after remat is saved in De...
const TargetRegisterInfo * TRI
virtual void postOptimization()
RegisterClassInfo RegClassInfo
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.
virtual void spill(LiveRangeEdit &LRE, AllocationOrder *Order=nullptr)=0
spill - Spill the LRE.getParent() live interval.
Calculate auxiliary information for a virtual register such as its spill weight and allocation hint.
void calculateSpillWeightsAndHints()
Compute spill weights and allocation hints for all virtual register live intervals.
bool hasPhys(Register virtReg) const
returns true if the specified virtual register is mapped to a physical register
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.
LLVM_ABI char & MachineDominatorsID
MachineDominators - This pass is a machine dominators analysis pass.
auto reverse(ContainerTy &&C)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI FunctionPass * createBasicRegisterAllocator()
BasicRegisterAllocation Pass - This pass implements a degenerate global register allocator using the ...
Spiller * createInlineSpiller(const Spiller::RequiredAnalyses &Analyses, MachineFunction &MF, VirtRegMap &VRM, VirtRegAuxInfo &VRAI, LiveRegMatrix *Matrix=nullptr)
Create and return a spiller that will insert spill code directly instead of deferring though VirtRegM...
LLVM_ABI 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.
LLVM_ABI char & RABasicID
Basic register allocator.