79 unsigned NextCascade = 1;
93 Info[
Reg].Stage = Stage;
111 Info[
Reg].Cascade = Cascade;
117 Cascade = NextCascade++;
126 Cascade = NextCascade;
130 template <
typename Iterator>
132 for (; Begin != End; ++Begin) {
136 Info[
Reg].Stage = NewStage;
152 return RegClassPriorityTrumpsGlobalness;
159 using PQueue = std::priority_queue<std::pair<unsigned, unsigned>>;
164 using RecoloringStack =
188 std::unique_ptr<Spiller> SpillerInstance;
190 std::unique_ptr<VirtRegAuxInfo> VRAI;
191 std::optional<ExtraRegInfo> ExtraInfo;
192 std::unique_ptr<RegAllocEvictionAdvisor> EvictAdvisor;
194 std::unique_ptr<RegAllocPriorityAdvisor> PriorityAdvisor;
210 uint8_t CutOffInfo = CutOffStage::CO_None;
213 static const char *
const StageName[];
217 std::unique_ptr<SplitAnalysis> SA;
218 std::unique_ptr<SplitEditor> SE;
221 InterferenceCache IntfCache;
224 SmallVector<SpillPlacement::BlockConstraint, 8> SplitConstraints;
227 struct GlobalSplitCandidate {
235 InterferenceCache::Cursor Intf;
238 BitVector LiveBundles;
239 SmallVector<unsigned, 8> ActiveBlocks;
241 void reset(InterferenceCache &Cache, MCRegister
Reg) {
244 Intf.setPhysReg(Cache,
Reg);
246 ActiveBlocks.clear();
250 unsigned getBundles(SmallVectorImpl<unsigned> &
B,
unsigned C) {
252 for (
unsigned I : LiveBundles.set_bits())
253 if (
B[
I] == NoCand) {
264 SmallVector<GlobalSplitCandidate, 32> GlobalCand;
266 enum :
unsigned {
NoCand = ~0
u };
270 SmallVector<unsigned, 32> BundleCand;
273 BlockFrequency CSRCost;
276 SmallSetVector<const LiveInterval *, 8> SetOfBrokenHints;
280 ArrayRef<uint8_t> RegCosts;
284 bool RegClassPriorityTrumpsGlobalness =
false;
286 bool ReverseLocalAssignment =
false;
289 RAGreedy(RequiredAnalyses &Analyses,
const RegAllocFilterFunc
F =
nullptr);
296 void aboutToRemoveInterval(
const LiveInterval &)
override;
301 void releaseMemory();
306 RecoloringStack &,
unsigned = 0);
308 bool LRE_CanEraseVirtReg(
Register)
override;
309 void LRE_WillShrinkVirtReg(
Register)
override;
314 bool hasVirtRegAlloc();
318 bool growRegion(GlobalSplitCandidate &Cand);
321 bool calcCompactRegion(GlobalSplitCandidate &);
326 bool mayRecolorAllInterferences(
MCRegister PhysReg,
328 SmallLISet &RecoloringCandidates,
339 unsigned calculateRegionSplitCostAroundReg(
MCRegister PhysReg,
345 unsigned calculateRegionSplitCost(
const LiveInterval &VirtReg,
348 unsigned &NumCands,
bool IgnoreCSR);
364 void initializeCSRCost();
380 void tryHintsRecoloring();
393 : Freq(Freq),
Reg(
Reg), PhysReg(PhysReg) {}
395 using HintsInfo = SmallVector<HintInfo, 4>;
397 BlockFrequency getBrokenHintFreq(
const HintsInfo &, MCRegister);
398 void collectHintInfo(
Register, HintsInfo &);
401 struct RAGreedyStats {
402 unsigned Reloads = 0;
403 unsigned FoldedReloads = 0;
404 unsigned ZeroCostFoldedReloads = 0;
406 unsigned FoldedSpills = 0;
408 float ReloadsCost = 0.0f;
409 float FoldedReloadsCost = 0.0f;
410 float SpillsCost = 0.0f;
411 float FoldedSpillsCost = 0.0f;
412 float CopiesCost = 0.0f;
415 return !(Reloads || FoldedReloads || Spills || FoldedSpills ||
416 ZeroCostFoldedReloads ||
Copies);
419 void add(
const RAGreedyStats &other) {
420 Reloads += other.Reloads;
421 FoldedReloads += other.FoldedReloads;
422 ZeroCostFoldedReloads += other.ZeroCostFoldedReloads;
423 Spills += other.Spills;
424 FoldedSpills += other.FoldedSpills;
426 ReloadsCost += other.ReloadsCost;
427 FoldedReloadsCost += other.FoldedReloadsCost;
428 SpillsCost += other.SpillsCost;
429 FoldedSpillsCost += other.FoldedSpillsCost;
430 CopiesCost += other.CopiesCost;
433 void report(MachineOptimizationRemarkMissed &R);
437 RAGreedyStats computeStats(MachineBasicBlock &
MBB);
440 RAGreedyStats reportStats(MachineLoop *L);