|
|
|
|
@ -532,6 +532,7 @@ static void AllocateRegistersForFunction(MachineFunction &function)
|
|
|
|
|
// ---- 阶段 0:活跃分析 + 预处理 ----
|
|
|
|
|
auto raw = ComputeInstLiveness(function);
|
|
|
|
|
auto intervals = EnhanceIntervals(raw, function);
|
|
|
|
|
intervals.reserve(function.GetNumVRegs() * 16);
|
|
|
|
|
|
|
|
|
|
auto &blocks = function.GetBlocks();
|
|
|
|
|
std::vector<int> pos_to_block;
|
|
|
|
|
@ -549,7 +550,7 @@ static void AllocateRegistersForFunction(MachineFunction &function)
|
|
|
|
|
auto block_depth = AnalyzeLoopDepth(function);
|
|
|
|
|
ComputeSpillWeights(intervals, block_depth, pos_to_block);
|
|
|
|
|
PropagateCopyHints(intervals, function);
|
|
|
|
|
intervals.reserve(function.GetNumVRegs() * 4);
|
|
|
|
|
intervals.reserve(function.GetNumVRegs() * 16);
|
|
|
|
|
|
|
|
|
|
// LLVM 风格:全局 cascade 计数器
|
|
|
|
|
int global_cascade = 1;
|
|
|
|
|
@ -661,6 +662,7 @@ static void AllocateRegistersForFunction(MachineFunction &function)
|
|
|
|
|
// ---- 重新分析活跃 ----
|
|
|
|
|
raw = ComputeInstLiveness(function);
|
|
|
|
|
intervals = EnhanceIntervals(raw, function);
|
|
|
|
|
intervals.reserve(function.GetNumVRegs() * 16);
|
|
|
|
|
|
|
|
|
|
// ---- 重建位置映射 ----
|
|
|
|
|
pos_to_block.clear();
|
|
|
|
|
|