77 unsigned NextCascade = 1;
91 Info[
Reg].Stage = Stage;
109 Info[
Reg].Cascade = Cascade;
115 Cascade = NextCascade++;
124 Cascade = NextCascade;
128 template <
typename Iterator>
130 for (; Begin !=
End; ++Begin) {
134 Info[
Reg].Stage = NewStage;
150 return RegClassPriorityTrumpsGlobalness;
157 using PQueue = std::priority_queue<std::pair<unsigned, unsigned>>;
162 using RecoloringStack =
186 std::unique_ptr<Spiller> SpillerInstance;
188 std::unique_ptr<VirtRegAuxInfo> VRAI;
189 std::optional<ExtraRegInfo> ExtraInfo;
190 std::unique_ptr<RegAllocEvictionAdvisor> EvictAdvisor;
192 std::unique_ptr<RegAllocPriorityAdvisor> PriorityAdvisor;
208 uint8_t CutOffInfo = CutOffStage::CO_None;
211 static const char *
const StageName[];
215 std::unique_ptr<SplitAnalysis> SA;
216 std::unique_ptr<SplitEditor> SE;
219 InterferenceCache IntfCache;
222 SmallVector<SpillPlacement::BlockConstraint, 8> SplitConstraints;
225 struct GlobalSplitCandidate {
233 InterferenceCache::Cursor Intf;
236 BitVector LiveBundles;
237 SmallVector<unsigned, 8> ActiveBlocks;
239 void reset(InterferenceCache &Cache, MCRegister
Reg) {
242 Intf.setPhysReg(Cache,
Reg);
244 ActiveBlocks.clear();
248 unsigned getBundles(SmallVectorImpl<unsigned> &
B,
unsigned C) {
250 for (
unsigned I : LiveBundles.set_bits())
251 if (
B[
I] == NoCand) {
262 SmallVector<GlobalSplitCandidate, 32> GlobalCand;
264 enum :
unsigned {
NoCand = ~0
u };
268 SmallVector<unsigned, 32> BundleCand;
271 BlockFrequency CSRCost;
274 SmallSetVector<const LiveInterval *, 8> SetOfBrokenHints;
278 ArrayRef<uint8_t> RegCosts;
282 bool RegClassPriorityTrumpsGlobalness =
false;
284 bool ReverseLocalAssignment =
false;
287 RAGreedy(RequiredAnalyses &Analyses,
const RegAllocFilterFunc
F =
nullptr);
294 void aboutToRemoveInterval(
const LiveInterval &)
override;
299 void releaseMemory();
304 RecoloringStack &,
unsigned = 0);
306 bool LRE_CanEraseVirtReg(
Register)
override;
307 void LRE_WillShrinkVirtReg(
Register)
override;
312 bool hasVirtRegAlloc();
317 bool growRegion(GlobalSplitCandidate &Cand);
320 bool calcCompactRegion(GlobalSplitCandidate &);
325 bool mayRecolorAllInterferences(
MCRegister PhysReg,
327 SmallLISet &RecoloringCandidates,
338 unsigned calculateRegionSplitCostAroundReg(
MCRegister PhysReg,
344 unsigned calculateRegionSplitCost(
const LiveInterval &VirtReg,
347 unsigned &NumCands,
bool IgnoreCSR);
367 void initializeCSRCost();
383 void tryHintsRecoloring();
398 using HintsInfo = SmallVector<HintInfo, 4>;
400 BlockFrequency getBrokenHintFreq(
const HintsInfo &, MCRegister);
401 void collectHintInfo(
Register, HintsInfo &);
404 struct RAGreedyStats {
405 unsigned Reloads = 0;
406 unsigned FoldedReloads = 0;
407 unsigned ZeroCostFoldedReloads = 0;
409 unsigned FoldedSpills = 0;
411 float ReloadsCost = 0.0f;
412 float FoldedReloadsCost = 0.0f;
413 float SpillsCost = 0.0f;
414 float FoldedSpillsCost = 0.0f;
415 float CopiesCost = 0.0f;
418 return !(Reloads || FoldedReloads || Spills || FoldedSpills ||
419 ZeroCostFoldedReloads ||
Copies);
422 void add(
const RAGreedyStats &other) {
423 Reloads += other.Reloads;
424 FoldedReloads += other.FoldedReloads;
425 ZeroCostFoldedReloads += other.ZeroCostFoldedReloads;
426 Spills += other.Spills;
427 FoldedSpills += other.FoldedSpills;
429 ReloadsCost += other.ReloadsCost;
430 FoldedReloadsCost += other.FoldedReloadsCost;
431 SpillsCost += other.SpillsCost;
432 FoldedSpillsCost += other.FoldedSpillsCost;
433 CopiesCost += other.CopiesCost;
436 void report(MachineOptimizationRemarkMissed &R);
440 RAGreedyStats computeStats(MachineBasicBlock &
MBB);
443 RAGreedyStats reportStats(MachineLoop *L);