fix(mir): 别名无条件冲突 + per-round reserve防指针失效

两个安全修复:
1. GPR32/GPR64别名检查移除segments.empty()条件
   Wn/Xn是同一硬件寄存器,GPR32和GPR64 vreg在同一phys_reg上总是冲突
2. 每轮EnhancerIntervals后reserve*16,防止push_back导致reg_assignments_指针失效

当前正确率:94% (94/100)
lzk
lzkk 4 days ago
parent d6f42a2a2e
commit bfe105c2cd

@ -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();

Loading…
Cancel
Save