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();
319 bool growRegion(GlobalSplitCandidate &Cand);
322 bool calcCompactRegion(GlobalSplitCandidate &);
327 bool mayRecolorAllInterferences(
MCRegister PhysReg,
329 SmallLISet &RecoloringCandidates,
340 unsigned calculateRegionSplitCostAroundReg(
MCRegister PhysReg,
346 unsigned calculateRegionSplitCost(
const LiveInterval &VirtReg,
349 unsigned &NumCands,
bool IgnoreCSR);
369 void initializeCSRCost();
385 void tryHintsRecoloring();
400 using HintsInfo = SmallVector<HintInfo, 4>;
402 BlockFrequency getBrokenHintFreq(
const HintsInfo &, MCRegister);
403 void collectHintInfo(
Register, HintsInfo &);
406 struct RAGreedyStats {
407 unsigned Reloads = 0;
408 unsigned FoldedReloads = 0;
409 unsigned ZeroCostFoldedReloads = 0;
411 unsigned FoldedSpills = 0;
413 float ReloadsCost = 0.0f;
414 float FoldedReloadsCost = 0.0f;
415 float SpillsCost = 0.0f;
416 float FoldedSpillsCost = 0.0f;
417 float CopiesCost = 0.0f;
420 return !(Reloads || FoldedReloads || Spills || FoldedSpills ||
421 ZeroCostFoldedReloads ||
Copies);
424 void add(
const RAGreedyStats &other) {
425 Reloads += other.Reloads;
426 FoldedReloads += other.FoldedReloads;
427 ZeroCostFoldedReloads += other.ZeroCostFoldedReloads;
428 Spills += other.Spills;
429 FoldedSpills += other.FoldedSpills;
431 ReloadsCost += other.ReloadsCost;
432 FoldedReloadsCost += other.FoldedReloadsCost;
433 SpillsCost += other.SpillsCost;
434 FoldedSpillsCost += other.FoldedSpillsCost;
435 CopiesCost += other.CopiesCost;
438 void report(MachineOptimizationRemarkMissed &R);
442 RAGreedyStats computeStats(MachineBasicBlock &
MBB);
445 RAGreedyStats reportStats(MachineLoop *L);